Microsoft.Windows.TimedScript.PropertyBagProvider
Updated: August 10, 2011
Applies To: Operations Manager 2007 R2
The Microsoft.Windows.TimedScript.PropertyBagProvider data source module type is used to run a script as part of a scheduled workflow. This module type returns System.PropertyBagDatadata.
Usage
Use this module when you want to gather data from a scheduled script on a monitored computer to return property bag data in in task, rule, or monitor workflow.
Type Definition
<DataSourceModuleType ID="Microsoft.Windows.TimedScript.PropertyBagProvider" Accessibility="Public" Batching="false"> <Configuration> <IncludeSchemaTypes> <SchemaType>System!System.ExpressionEvaluatorSchema</SchemaType> <SchemaType>System!System.CommandExecuterSchema</SchemaType> </IncludeSchemaTypes> <xsd:element name="IntervalSeconds" type="xsd:int" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /> <xsd:element name="SyncTime" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /> <xsd:element name="ScriptName" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /> <xsd:element name="Arguments" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /> <xsd:element name="ScriptBody" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /> <xsd:element name="SecureInput" minOccurs="0" maxOccurs="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="256" /> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="TimeoutSeconds" type="xsd:integer" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /> <xsd:element minOccurs="0" maxOccurs="1" name="EventPolicy" type="CommandExecuterEventPolicyType" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /> </Configuration> <OverrideableParameters> <OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int" /> <OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string" /> <OverrideableParameter ID="Arguments" Selector="$Config/Arguments$" ParameterType="string" /> <OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int" /> </OverrideableParameters> <ModuleImplementation Isolation="Any"> <Composite> <MemberModules> <DataSource ID="DS1" TypeID="System!System.SimpleScheduler"> <IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds> <SyncTime>$Config/SyncTime$</SyncTime> </DataSource> <ProbeAction ID="Script" TypeID="Microsoft.Windows.ScriptPropertyBagProbe"> <ScriptName>$Config/ScriptName$</ScriptName> <Arguments>$Config/Arguments$</Arguments> <ScriptBody>$Config/ScriptBody$</ScriptBody> <SecureInput>$Config/SecureInput$</SecureInput> <TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds> <EventPolicy>$Config/EventPolicy$</EventPolicy> </ProbeAction> </MemberModules> <Composition> <Node ID="Script"> <Node ID="DS1" /> </Node> </Composition> </Composite> </ModuleImplementation> <OutputType>System!System.PropertyBagData</OutputType> </DataSourceModuleType> >
Parameters
The Microsoft.Windows.TimedScript.PropertyBagProvider module supports the configuration parameters described in the following table.
Parameter | Type | Overrideable | Description |
---|---|---|---|
IntervalSeconds | Integer | True | Required parameter. The recurring interval of time in seconds in which to run the script. |
SyncTime | String | True | Required parameter. The synchronization time specified by using a 24-hour format. If you do not want to specify a synchronization time, you can include the element, but without any value (for example, <SyncTime/>). |
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 | False | Optional parameter. Defines the expected output and the behavior based on unexpected output from the script |
For more information about the IntervalSeconds and SyncTime parameters of this module, see PublicSchedulerType.
For more information about the remaining parameters of this module, see Microsoft.Windows.ScriptProbeAction.
Composition
The Microsoft.Windows.TimedScript.PropertyBagProvider module is a composite module that contains the member modules described in the following table.
Workflow Run Order | Module Type | Usage |
---|---|---|
1 | Triggers the subsequent discovery script to run at the specified scheduled interval and synchronization time. | |
2 | Runs the script and returns the property bag data. |
Remarks
For more information about writing Operations Manager discovery and monitoring scripts, see Operations Manager 2007 R2 Scripting Objects.
Related Modules
Module Type | Usage |
Used for discovery scripts that are triggered by data sources other than the simple scheduler. | |
Used for discovery scripts that are triggered by data sources other than the simple scheduler. | |
Used as a task or recovery when the script is changing something on the system on which it is run. | |
Used for scheduled discovery scripts that are triggered by the simple scheduler. | |
Used for scheduled scripts that output data that is mapped to an event and stored in the Operations Manager databases. |
External Module References
None.
Sample
The following XML sample illustrates how to use the Microsoft.Windows.TimedScript.PropertyBagProvider from within a tri-state threshold unit monitor type that monitors the available free Operations Manager database space. The script will run, collect the desired data, and return that data as a property bag type. The three states of the monitor are determined based on whether the returned values fall outside of a desirable threshold.
The following portion of the sample is a definition of the UnitMonitorType. The Microsoft.SystemCenter.OpsMgrDBPercentFreeSpaceProvider data source module that is implemented in this unit monitor type contains the Microsoft.Windows.TimedScript.PropertyBagProvider module as a member module. The next portion of the sample shows the type definition of theMicrosoft.SystemCenter.OpsMgrDBPercentFreeSpaceProvider module.
<UnitMonitorType ID="Microsoft.SystemCenter.OpsMgrDBPercentFreeSpaceMonitorType" Accessibility="Internal"> <MonitorTypeStates> <MonitorTypeState ID="UnderErrorThreshold" NoDetection="false" /> <MonitorTypeState ID="OverErrorThresholdUnderWarningThreshold" NoDetection="false" /> <MonitorTypeState ID="OverWarningThreshold" NoDetection="false" /> </MonitorTypeStates> <Configuration> <xsd:element name="IntervalSeconds" type="xsd:integer" /> <xsd:element name="DatabaseServerName" type="xsd:string" /> <xsd:element name="DatabaseName" type="xsd:string" /> <xsd:element name="ErrorThreshold" type="xsd:double" /> <xsd:element name="WarningThreshold" type="xsd:double" /> <xsd:element name="TimeoutSeconds" type="xsd:int" /> </Configuration> <OverrideableParameters> <OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int" /> <OverrideableParameter ID="ErrorThreshold" Selector="$Config/ErrorThreshold$" ParameterType="double" /> <OverrideableParameter ID="WarningThreshold" Selector="$Config/WarningThreshold$" ParameterType="double" /> <OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int" /> </OverrideableParameters> <MonitorImplementation> <MemberModules> <DataSource ID="DS" TypeID="Microsoft.SystemCenter.OpsMgrDBPercentFreeSpaceProvider"> <IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds> <DatabaseServerName>$Config/DatabaseServerName$</DatabaseServerName> <DatabaseName>$Config/DatabaseName$</DatabaseName> <TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds> </DataSource> <ConditionDetection ID="CDUnderErrorThreshold" TypeID="System!System.ExpressionFilter"> <Expression> <SimpleExpression> <ValueExpression> <XPathQuery Type="Double">Property[@Name='DBPercentFreeSpace']</XPathQuery> </ValueExpression> <Operator>Less</Operator> <ValueExpression> <Value Type="Double">$Config/ErrorThreshold$</Value> </ValueExpression> </SimpleExpression> </Expression> </ConditionDetection> <ConditionDetection ID="CDOverErrorThresholdUnderWarningThreshold" TypeID="System!System.ExpressionFilter"> <Expression> <And> <Expression> <SimpleExpression> <ValueExpression> <XPathQuery Type="Double">Property[@Name='DBPercentFreeSpace']</XPathQuery> </ValueExpression> <Operator>GreaterEqual</Operator> <ValueExpression> <Value Type="Double">$Config/ErrorThreshold$</Value> </ValueExpression> </SimpleExpression> </Expression> <Expression> <SimpleExpression> <ValueExpression> <XPathQuery Type="Double">Property[@Name='DBPercentFreeSpace']</XPathQuery> </ValueExpression> <Operator>LessEqual</Operator> <ValueExpression> <Value Type="Double">$Config/WarningThreshold$</Value> </ValueExpression> </SimpleExpression> </Expression> </And> </Expression> </ConditionDetection> <ConditionDetection ID="CDOverWarningThreshold" TypeID="System!System.ExpressionFilter"> <Expression> <SimpleExpression> <ValueExpression> <XPathQuery Type="Double">Property[@Name='DBPercentFreeSpace']</XPathQuery> </ValueExpression> <Operator>Greater</Operator> <ValueExpression> <Value Type="Double">$Config/WarningThreshold$</Value> </ValueExpression> </SimpleExpression> </Expression> </ConditionDetection> </MemberModules> <RegularDetections> <RegularDetection MonitorTypeStateID="UnderErrorThreshold"> <Node ID="CDUnderErrorThreshold"> <Node ID="DS" /> </Node> </RegularDetection> <RegularDetection MonitorTypeStateID="OverErrorThresholdUnderWarningThreshold"> <Node ID="CDOverErrorThresholdUnderWarningThreshold"> <Node ID="DS" /> </Node> </RegularDetection> <RegularDetection MonitorTypeStateID="OverWarningThreshold"> <Node ID="CDOverWarningThreshold"> <Node ID="DS" /> </Node> </RegularDetection> </RegularDetections> </MonitorImplementation> </UnitMonitorType>
The following section of this sample shows how the Microsoft.Windows.TimedScript.PropertyBagProvider module is implemented as a member of theMicrosoft.SystemCenter.OpsMgrDBPercentFreeSpaceProvider module.
<DataSourceModuleType ID="Microsoft.SystemCenter.OpsMgrDBPercentFreeSpaceProvider" Accessibility="Internal" RunAs="SCLibrary!Microsoft.SystemCenter.DatabaseWriteActionAccount" Batching="false"> <Configuration> <xsd:element name="IntervalSeconds" type="xsd:integer" /> <xsd:element name="DatabaseServerName" type="xsd:string" /> <xsd:element name="DatabaseName" type="xsd:string" /> <xsd:element name="TimeoutSeconds" type="xsd:int" /> </Configuration> <OverrideableParameters> <OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int" /> <OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int" /> </OverrideableParameters> <ModuleImplementation Isolation="Any"> <Composite> <MemberModules> <DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.PropertyBagProvider"> <IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds> <SyncTime /> <ScriptName>GetOpsMgrDBPercentFreeSpace.vbs</ScriptName> <Arguments>$Config/DatabaseServerName$ $Config/DatabaseName$</Arguments> <ScriptBody> <![CDATA[ 'Copyright (c) Microsoft Corporation. All rights reserved. ' Parameters that should be passed to this script ' 0 DatabaseServerName ' 1 DatabaseName Option Explicit SetLocale("en-us") Const SQL_DISCOVERY_SUCCESS = 0 Dim oArgs, databaseServerName, databaseName Set oArgs = WScript.Arguments If oArgs.Count <> 2 Then Wscript.Quit -1 End If databaseServerName = oArgs(0) databaseName = oArgs(1) Dim oAPI, oSQLPropertyBag Set oAPI = CreateObject("MOM.ScriptAPI") set oSQLPropertyBag = oAPI.CreatePropertyBag() 'Set the connection string Dim connectionString connectionString = "Provider=sqloledb;Server=" & _ databaseServerName & ";" & _ "Integrated Security=SSPI;Initial Catalog=" & databaseName If GetDBFreeSpace(connectionString, oSQLPropertyBag) = SQL_DISCOVERY_SUCCESS Then Call oAPI.Return(oSQLPropertyBag) WScript.Quit() Function GetDBFreeSpace(ByVal connectionString, ByVal oSQLPropertyBag) Dim cnADOConnection Set cnADOConnection = CreateObject("ADODB.Connection") cnADOConnection.Open connectionString cnADOConnection.CommandTimeout = 300 Dim oResults, dDBUnallocatedSpace, dDBPercentFreeSpace Set oResults = cnADOConnection.Execute("exec sp_spaceused") dDBUnallocatedSpace = ConvertSizeStringToNumber(Trim(oResults(2))) Dim oResultsSize, dbDataSize Set oResultsSize = cnADOConnection.Execute("exec sp_helpfile") 'Convert from Kb to Mb dbDataSize = ConvertSizeStringToNumber(Trim(oResultsSize(4))) dbDataSize = dbDataSize / 1024 dDBPercentFreeSpace = Round((dDBUnallocatedSpace / dbDataSize) * 100, 2) oSQLPropertyBag.AddValue "DBPercentFreeSpace", dDBPercentFreeSpace Set oResults = nothing cnADOConnection.Close GetDBFreeSpace = SQL_DISCOVERY_SUCCESS End Function Function ConvertSizeStringToNumber(sSizeString) ' Remove the MB and return a valid double sSizeString = Replace(sSizeString, " KB", "") sSizeString = Replace(sSizeString, " MB", "") ConvertSizeStringToNumber = CDbl(sSizeString) End Function ]]> </ScriptBody> <TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds> </DataSource> </MemberModules> <Composition> <Node ID="DS" /> </Composition> </Composite> </ModuleImplementation> <OutputType>System!System.PropertyBagData</OutputType> </DataSourceModuleType>
Information
Module Type | |
Input Type | None. |
Output Type | |
Implementation | Composite |
Library | Microsoft.Windows.Library |