Microsoft.Windows.TimedScript.EventProvider

System Center

Updated: May 18, 2012

Applies To: System Center 2012 - Operations Manager, System Center 2012 R2 Operations Manager, System Center 2012 SP1 - Operations Manager

The Microsoft.Windows.TimedScript.EventProvider data source module type is used to run a script as part of a scheduled workflow. This module type returns System.Event.Data data.

Usage

Use this module when you want to gather data from a scheduled script on a monitored computer to return the specified event data in a task, rule, or monitor workflow. This module is useful if you want to map any type of data that can be accessed through script to event data.

Type Definition


<DataSourceModuleType ID="Microsoft.Windows.TimedScript.EventProvider" Accessibility="Public">
  <Configuration>
    <IncludeSchemaTypes>
      <SchemaType>System!System.ParamListSchema</SchemaType>
      <SchemaType>System!System.ExpressionEvaluatorSchema</SchemaType>
      <SchemaType>System!System.CommandExecuterSchema</SchemaType>
    </IncludeSchemaTypes>
    <xsd:element name="IntervalSeconds" type="xsd:int" />
    <xsd:element name="SyncTime" type="xsd:string" />
    <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" />
    <xsd:element name="EventOriginId" type="xsd:string" />
    <xsd:element name="PublisherId" type="xsd:string" />
    <xsd:element name="PublisherName" type="xsd:string" />
    <xsd:element name="Channel" type="xsd:string" />
    <xsd:element name="LoggingComputer" type="xsd:string" />
    <xsd:element name="EventNumber" type="xsd:string" />
    <xsd:element name="EventCategory" type="xsd:string" />
    <xsd:element name="EventLevel" type="xsd:string" />
    <xsd:element name="UserName" type="xsd:string" />
    <xsd:element name="Description" type="xsd:string" minOccurs="0" maxOccurs="1" />
    <xsd:element name="Params" type="ParamListType" />
  </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>
    <Composite>
      <MemberModules>
        <DataSource TypeID="Microsoft.Windows.TimedScript.PropertyBagProvider" ID="DS1">
          <IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
          <SyncTime>$Config/SyncTime$</SyncTime>
          <ScriptName>$Config/ScriptName$</ScriptName>
          <Arguments>$Config/Arguments$</Arguments>
          <ScriptBody>$Config/ScriptBody$</ScriptBody>
          <SecureInput>$Config/SecureInput$</SecureInput>
          <TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
          <EventPolicy>$Config/EventPolicy$</EventPolicy>
        </DataSource>
        <ConditionDetection TypeID="System!System.Event.GenericDataMapper" ID="Mapper1">
          <EventOriginId>$Config/EventOriginId$</EventOriginId>
          <PublisherId>$Config/PublisherId$</PublisherId>
          <PublisherName>$Config/PublisherName$</PublisherName>
          <Channel>$Config/Channel$</Channel>
          <LoggingComputer>$Config/LoggingComputer$</LoggingComputer>
          <EventNumber>$Config/EventNumber$</EventNumber>
          <EventCategory>$Config/EventCategory$</EventCategory>
          <EventLevel>$Config/EventLevel$</EventLevel>
          <UserName>$Config/UserName$</UserName>
          <Description>$Config/Description$</Description>
          <Params>$Config/Params$</Params>
        </ConditionDetection>
      </MemberModules>
      <Composition>
        <Node ID="Mapper1">
          <Node ID="DS1" />
        </Node>
      </Composition>
    </Composite>
  </ModuleImplementation>
  <OutputType>System!System.Event.Data</OutputType>
</DataSourceModuleType>

Parameters

The Microsoft.Windows.TimedScript.EventProvider 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

CommandExecuterEventPolicyType

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.EventProvider module is a composite module that contains the member modules described in the following table.

 

Workflow Run Order Module Type Usage

1

Microsoft.Windows.TimedScript.PropertyBagProvider

Runs the script at the specified schedule and returns the resulting data as property bag data.

2

System.Event.GenericDataMapper

Maps each entry in the property bag data to event 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

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.ScriptPropertyBagProbe

Used for monitoring 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.

External Module References

None.

Sample

The following XML sample illustrates how to use the Microsoft.Windows.TimedScript.EventProvider within a rule to generate event and alert data from an XML file that contains records in an arbitrary third-party format. For every Record element that exists within the XML document, a property bag is created to contain the values of its attributes. After the property bag has been mapped to event data, the three write actions are performed.


<Rule ID="Microsoft.Samples.XmlToEventData " Enabled="false" Target="Windows!Microsoft.Windows.Computer " ConfirmDelivery="false" Remotable="true" Priority="Normal" DiscardLevel="100">
  <Category>EventCollection</Category>
  <DataSources>
    <DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.EventProvider">
      <IntervalSeconds>3600</IntervalSeconds>
      <SyncTime />
      <ScriptName>XmlToEventData.vbs</ScriptName>
      <Arguments />
      <ScriptBody>
        <![CDATA[

Dim MomScriptAPI
Set MomScriptAPI= CreateObject("MOM.ScriptAPI")

Dim oDom
Set oDom = CreateObject("Microsoft.XMLDOM")
oDom.Async = false

If oDom.Load("C:\Application\xmlDoc.xml") Then
   Set records = oDom.getElementsByTagName("Record")
   For i=0 To records.Length - 1
      Set record = records.nextNode()
      Dim propBag
      Set propBag = MOMScriptAPI.CreatePropertyBag()
   
      Call propBag.AddValue("ProductName", record.getAttribute("ProductName")
      Call propBag.AddValue("PublisherName", record.getAttribute("Publisher")
      Call propBag.AddValue("Description", record.getAttribute("Description")
      Call propBag.AddValue("Param1", record.getAttribute("URLHelp")
      Call propBag.AddValue("EventType", record.getAttribute("EventType")
      Call propBag.AddValue("ID", record.getAttribute("ID")

      MOMScriptAPI.AddItem(propBag)
   Next

MOMScriptAPI.ReturnItems()

]]>
      </ScriptBody>
      <TimeoutSeconds>$Config/TimeoutSeconds</TimeoutSeconds>
      <EventOriginId>$MPElement$</EventOriginId>
      <PublisherId>$MPElement$</PublisherId>
      <PublisherName>$Data/Property[@Name=’ProductName’]$</PublisherName>
      <Channel>XmlRecordsEventLog</Channel>
      <LoggingComputer>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetbiosComputerName$</LoggingComputer>
      <EventNumber>$Data/Property[@Name=’ID’]$</EventNumber>
      <EventCategory>1</EventCategory>
      <EventLevel>$Data/Property[@Name=’EventType’]$</EventLevel>
      <UserName />
      <Description>>$Data/Property[@Name=’Description’]$</Description>
      <Params>
        <Param>$Data/Property[@Name='Param1']$</Param>
      </Params>
    </DataSource>
  </DataSources>
  <WriteActions>
    <WriteAction ID="WriteToDB" TypeID="SC!Microsoft.SystemCenter.CollectEvent" />
    <WriteAction ID="WriteToDW" TypeID="SCDW!Microsoft.SystemCenter.DataWarehouse.PublishEventData" />
    <WriteAction ID="Alert" TypeID="Health!System.Health.GenerateAlert">
      <Priority>1</Priority>
      <Severity>2</Severity>
      <AlertMessageId>$MPElement[Name="Microsoft.Samples.SomeAlertMessageID"]$</AlertMessageId>
      <AlertParameters>
        <AlertParameter1>$Data/EventDescription$</AlertParameter1>
     </AlertParameters>
      <Suppression>
        <SuppressionValue>$Data/EventDisplayNumber$</SuppressionValue>
        <SuppressionValue>$Data/LoggingComputer$</SuppressionValue>
      </Suppression>
      <Custom1>$Data/Params/Param[1]$</Custom1>
      <Custom2 />
      <Custom3 />
      <Custom4 />
      <Custom5 />
      <Custom6 />
      <Custom7 />
      <Custom8/>
      <Custom9/>
      <Custom10 />
    </WriteAction>
  </WriteActions>
</Rule>

The contents of the XML file used in the preceding sample would be something like the following:


<Records>
   <Record ID="1" ProductName="MyProduct" Publisher="MyPublisher" Description="The description 1" URLHelp="http://www.microsoft.com/help" EventType="2"></Record>
   <Record ID="2" ProductName="MyProduct" Publisher="MyPublisher" Description="The description 2" URLHelp="http://www.microsoft.com/help" EventType="3"></Record>
   <Record ID="3" ProductName="MyProduct" Publisher="MyPublisher" Description="The description 3" URLHelp="http://www.microsoft.com/help" EventType="3"></Record>
</Records>

Information

 

   

Module Type

DataSourceModuleType

Input Type

None.

Output Type

System.Event.Data

Implementation

Composite

Library

Microsoft.Windows.Library

 
Show: