Microsoft.Windows.ScriptPropertyBagProbe

Applies To: Operations Manager 2007 R2

The Microsoft.Windows.ScriptPropertyBagProbe probe action module type is used to run a script as part of a workflow. The module type accepts System.BaseData data, and the script it contains outputs System.PropertyBagData data.

Usage

Use this module when you want to gather data from a script on a monitored computer to return property bag data in a workflow. This module generally needs to be used only for monitoring scripts that are triggered by data sources other than the simple scheduler. If you need a data source module type that implements a simple scheduler, use the Microsoft.Windows.TimedScript.PropertyBagProvider module instead.

Type Definition

<ProbeActionModuleType ID="Microsoft.Windows.ScriptPropertyBagProbe" Accessibility="Public" PassThrough="false" Batching="false">
  <Configuration>
    <IncludeSchemaTypes>
      <SchemaType>System!System.CommandExecuterSchema</SchemaType>
    </IncludeSchemaTypes>
    <xsd:element name="ScriptName" type="xsd:string" />
    <xsd:element name="Arguments" type="xsd:string" />
    <xsd:element name="ScriptBody" type="xsd:string" />
    <xsd:element name="SecureInput" minOccurs="0" maxOccurs="1">
      <xsd:simpleType>
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="256" />
        </xsd:restriction>
      </xsd:simpleType>
    </xsd:element>
    <xsd:element name="TimeoutSeconds" type="xsd:integer" />
    <xsd:element minOccurs="0" maxOccurs="1" name="EventPolicy" type="CommandExecuterEventPolicyType" />
  </Configuration>
  <OverrideableParameters>
    <OverrideableParameter ID="Arguments" Selector="$Config/Arguments$" ParameterType="string" />
    <OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int" />
  </OverrideableParameters>
  <ModuleImplementation>
    <Composite>
      <MemberModules>
        <ProbeAction TypeID="Microsoft.Windows.ScriptProbePropertyBagBase" ID="Script">
          <ApplicationName><![CDATA[%windir%\system32\cscript.exe]]></ApplicationName>
          <WorkingDirectory />
          <CommandLine>/nologo "$Config/ScriptName$" $Config/Arguments$</CommandLine>
          <SecureInput>$Config/SecureInput$</SecureInput>
          <TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
          <RequireOutput>true</RequireOutput>
          <Files>
            <File>
              <Name>$Config/ScriptName$</Name>
              <Contents>$Config/ScriptBody$</Contents>
              <Unicode>true</Unicode>
            </File>
          </Files>
          <OutputType>System.PropertyBagData</OutputType>
          <DefaultEventPolicy>
            <StdOutMatches Operator="DoesNotMatchRegularExpression"><![CDATA[{<DataItem.+/DataItem\b*>}|{<DataItem.*/>}]]></StdOutMatches>
            <StdErrMatches>\a+</StdErrMatches>
            <ExitCodeMatches>[^0]+</ExitCodeMatches>
          </DefaultEventPolicy>
          <EventPolicy>$Config/EventPolicy$</EventPolicy>
        </ProbeAction>
      </MemberModules>
      <Composition>
        <Node ID="Script" />
      </Composition>
    </Composite>
  </ModuleImplementation>
  <OutputType>System!System.PropertyBagData</OutputType>
  <InputType>System!System.BaseData</InputType>
</ProbeActionModuleType>

Parameters

The Microsoft.Windows.ScriptPropertyBagProbe module supports the configuration parameters described in the following table.

Parameter Type Overrideable Description

ScriptName

String

False

Required parameter. Contains the file name of the script (including the extension) that identifies the script type.

Arguments

String

True

Required parameter. Contains the arguments to be supplied to the script on execution.

ScriptBody

String

False

Required parameter. Contains the script contents. If the script contains XML characters that must be escaped, it is recommended that the entire script be wrapped in a CDATA element.

SecureInput

String

False

Optional parameter. Contains the data to be passed to the script in a secure method. This is used to provide passwords to the script to be used during execution. Maximum length of the string is 256 characters.

TimeoutSeconds

Integer

True

Required parameter. Specifies the time the script is allowed to run before being closed by the module and marked as failed.

EventPolicy

CommandExecuterEventPolicyType

False

Optional parameter. Defines the expected output and the behavior based on unexpected output from the script

For more information about all parameters of this module, see Microsoft.Windows.ScriptProbeAction.

Composition

The Microsoft.Windows.ScriptPropertyBagProbe module is a composite module that contains the member module described in the following table.

Workflow Run Order Module Type Usage

1

Microsoft.Windows.ScriptProbePropertyBagBase

Internal module.

Module Type

Usage

Microsoft.Windows.ScriptDiscoveryProbe

Used for discovery scripts that are triggered by data sources other than the simple scheduler.

Microsoft.Windows.ScriptProbeAction

Used for discovery scripts that are triggered by data sources other than the simple scheduler.

Microsoft.Windows.ScriptWriteAction

Used as a task or recovery when the script is changing something on the system on which it is run.

Microsoft.Windows.TimedScript.DiscoveryProvider

Used for scheduled discovery scripts that are triggered by the simple scheduler.

Microsoft.Windows.TimedScript.EventProvider

Used for scheduled scripts that output data that is mapped to an event and stored in the Operations Manager databases.

External Module References

The Microsoft.Windows.ScriptDiscoveryProbe module is a member of the module described in the following table.

Module Type Library Usage

Microsoft.Windows.TimedScript.PropertyBagProvider

Microsoft.Windows.Library

Used for scheduled scripts that are used in rule or monitor workflows. This module type provides property bag output that is better suited for XPath referencing and expression evaluation. This module is triggered by the simple scheduler.

Remarks

For remarks, see Microsoft.Windows.ScriptProbeAction.

Sample

The following XML sample shows an example of a task that uses the Microsoft.Windows.ScriptPropertyBagProbe module to retrieve performance data from the current SQL Server database.

<Task ID="Microsoft.Samples.GetDBPerformanceData" Enabled="true" Target="Microsoft.SQLServer.Database" ConfirmDelivery="true" Remotable="true" Priority="Normal" DiscardLevel="100">
        <Category>Custom</Category>
        <DataSources>
          <DataSource ID="Script" TypeID="Windows!Microsoft.Windows.ScriptPropertyBagProbe ">
            <ScriptName>GetPerformanceData.vbs</ScriptName>
            <Arguments/>
            <ScriptBody><![CDATA[
//Copyright (c) Microsoft Corporation. All rights reserved.

var ScriptArgs = WScript.Arguments;

if (ScriptArgs.Length == 1)
{
var SQLServer = GetDMOServer(SQLConnectionString);
var opsmgrAPI = new ActiveXObject("MOM.ScriptAPI");

for (i=1; i &lt;= SQLServer.Databases.Count + 1; i++)
{
var currentDB = SQLServer.Databases.ItemByID(i);

if ((currentDB.Status == DB_NORMAL ) || (currentDB.Status == DB_STANDBY))
{
var propertyBag = opsmgrAPI.CreateTypedPropertyBag(2);
var logSize, logAvailable, dbSize, dbAvailable,dbFree, dbPercentFree;
                  dbFree = 0;
                  dbPercentFree = 0;
logSize = currentDB.TransactionLog.Size;
logAvailable = currentDB.TransactionLog.SpaceAvailableInMB;
dbSize = currentDB.Size - logSize 
dbAvailable = currentDB.SpaceAvailableInMB - logAvailable

                  propertyBag.AddValue("Database", currentDB.Name);
propertyBag.AddValue("TransactionLogSize", logSize);
propertyBag.AddValue("TransactionLogFree", logAvailable);

if (logAvailable != 0) 
                     logAvailable = 100 * logAvailable / logSize;

               propertyBag.AddValue("TransactionLogPercentFree", logAvailable);
      
if ((currentDB.Name != "tempdb") && (currentDB.Name != "master") && (currentDB.Name != "msdb"))
{
                        dbFree = dbAvailable;
                        dbPercentFree = 100 * dbAvailable / dbSize;
}

      propertyBag.AddValue("DBSize", dbSize);
                  propertyBag.AddValue("DBFree", dbFree);
propertyBag.AddValue("DBPercentFree", dbPercentFree);

opsmgrAPI.AddItem(propertyBag);
}
}
opsmgrAPI.ReturnItems();
SQLServer.Close();

}

 ]]></ScriptBody>
  <TimeoutSeconds>30</TimeoutSeconds>

</Task>

The output of the task would look something like the following XML:

<DataItem type="System.PropertyBagData" time="2008-03-11T03:08:55.0343534-08:00" sourceHealthServiceId="0A0800A0-A802-E90B-6045-D961D516CA78">
   <Property Name="Database" VariantType="8">DatabaseName</Property>
   <Property Name="TransactionLogSize" VariantType="3">1000</Property>
   <Property Name="TransactionLogFree" VariantType="3">400</Property>
   <Property Name="TransactionLogPercentFree" VariantType="3">40</Property>
   <Property Name="DBSize" VariantType="3">1000</Property>
   <Property Name="DBFree" VariantType="3">900</Property>
   <Property Name="DBPercentFree" VariantType="3">90</Property>
</DataItem>

Information

   

Module Type

ProbeActionModuleType

Input Type

System.BaseData

Output Type

System.PropertyBagData

Implementation

Composite

Library

Microsoft.Windows.Library