Welcome to MSDN Blogs Sign in | Join | Help

Notes on System Center Operations Manager

Notes, troubleshooting, development and comments related to System Center Operations Manager

Syndication

News











All of my postings are provided "AS IS" with no warranties, and confer no rights. Use of included samples are subject to the terms specified at Microsoft.



Locations of visitors to this page

Locations of visitors to this page


Parameter replacements (part 3)

 

To continue Parameter replacements series, let’s remind ourselves that context parameters can be used and will be replaced by the runtime with the actual parameter value. So far I talked about Config and MPElement replacements before and now I will try to describe Target context parameter in this post …

 

Target Context Parameters

 

When a monitoring object (rule/monitor/task) is instantiated and executed for a managed entity instance, the monitoring object instance can retrieve its target managed entity specific context as part of the configuration. The following context is available for this monitoring object:

 

-          Any property of the targeted managed entity type including the ones inherited, if the type is derived from a base type.

-          Any property of the host type of the target managed entity type. Not only properties of the immediate host can be retrieved, as well as the properties the host of the host can be retrieved if exists.

 

MP author can access this context using MPTarget context parameter.

Syntax

 

Use the following syntax to retrieve the managed entity instance id:

$Target/Id$

 

Use the following syntax to retrieve the management group id or name of the target managed entity: (Note that every managed entity instance belongs to a management group.)

$Target/ManagementGroup/Id$

$Target/ManagementGroup/Name$

 

Use the following syntax to retrieve the target managed entity’s properties:

$Target/Property/<PropertyName>$

$Target/Property[Type=”<RelTypeName>”]/<PropertyName>$

$Target/Property[Type=”<MPAlias>!<RelTypeName>”]/<PropertyName>$

 

Use the following syntax to refer to a property of host of the target managed entity type in the hosting hierarchy

$Target/Host/Property[Type=”<RelTypeName>”]/<PropertyName>$

$Target/Host/Host/Property[Type=”<RelTypeName>”]/<PropertyName>$

 

Usage Note:

 

When a property name is referred as a target parameter, the property name has to be fully qualified. MPAlias needs to be pre-appended to the type name, if the type is not defined in the same MP where the target properties are referred. RelTypeName defines first non-abstract base class which defines property identified by PropertyName.

 

Example:

 

<Discovery ID="Sample" Target="Windows!Microsoft.Windows.Computer">

        <Category>Discovery</Category>

        <DiscoveryTypes />

        <DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">

          <IntervalSeconds>900</IntervalSeconds>

          <SyncTime />

          <ScriptName>sampleDiscovery.vbs</ScriptName>

          <Arguments>$MPElement$ $Target/Id$</Arguments>

          <ScriptBody><![CDATA[

Option Explicit

 

Dim oArgs

Set oArgs = WScript.Arguments

 

Dim SourceId, ManagedEntityId

SourceId = oArgs(0)

ManagedEntityId = oArgs(1)

 

Dim oApi

Set oApi = CreateObject("MOM.ScriptAPI")

Dim oData

Set oData = oApi.CreateDiscoveryData ( _

            0, _

            SourceId, _

            ManagedEntityId _

) …

 

<Rule ID=" AlertFromEvent111" Target="Windows!Microsoft.Windows.Computer">

  <Category>AvailabilityHealth</Category>

  <DataSources>

    <DataSource ID="DS" TypeID="Windows!Microsoft.Windows.EventProvider">

      <ComputerName>$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ComputerName>

      <LogName>Application</LogName>

      <Expression>

        <SimpleExpression>

          <ValueExpression>

            <XPathQuery>EventDisplayNumber</XPathQuery>

          </ValueExpression>

          <Operator>Equal</Operator>

          <ValueExpression>

            <Value>111</Value>

          </ValueExpression>

      </Expression>

    </DataSource>

  </DataSources>

  <WriteActions>

    <WriteAction ID="GenerateAlert" TypeID="SystemHealth!System.Health.GenerateAlert">

      <Priority>2</Priority>

      <Severity>1</Severity>

      <AlertMessageId>$MPElement[Name=" AlertFromEvent111.Message"]$</AlertMessageId>

      <AlertParameters>

        <AlertParameter1>$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</AlertParameter1>

        <AlertParameter2>$Data/EventDisplayNumber$</AlertParameter2>

      </AlertParameters>

      <Suppression>

        <SuppressionValue/>

      </Suppression>

    </WriteAction>

  </WriteActions>

</Rule>

 

Note:

 

Similarly to MPElement replacement, use of the Target context parameter may be hidden by use of our authoring tools as well. There is also some documentation within MSDN (OpsMgr scripting, Using Context Parameters in script, …) describing its use for OpsMgr scripting.

 

Also, please check back again, I will talk about last context parameter ($Data) which is probably most cryptic of all in my next post …

Published Saturday, November 17, 2007 3:00 PM by MSutara

Filed under:

Comments

# Parameter replacements (part 4) @ Tuesday, November 20, 2007 5:53 PM

Parameter replacements series

Notes on System Center Operations Manager

Anonymous comments are disabled
Page view tracker