Share via


System.Health.GenerateAlertForType

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

The System.Health.GenerateAlertForType write action module type takes System.BaseData type data as input and creates an alert for an instance of the specified type.

Usage

This module is commonly used to generate an alert, much like System.Health.GenerateAlert, but the purpose of System.Health.GenerateAlertForType is to create an alert for an instance of a class that is not the target of the rule or monitor. One example of when you may use this module might be a publisher/subscriber setup where an error event received on the subscriber computer indicates an error on the publisher.

Type Definition

<WriteActionModuleType ID="System.Health.GenerateAlertForType" Accessibility="Public" Batching="false">
  <Configuration>
    <IncludeSchemaTypes>
      <SchemaType>System.Health.AlertSchema</SchemaType>
      <SchemaType>System!System.ManagedEntityKeysSchema</SchemaType>
    </IncludeSchemaTypes>
    <xsd:element name="Priority" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:simpleType>
        <xsd:restriction base="xsd:integer">
          <xsd:minInclusive value="0" />
          <xsd:maxInclusive value="2" />
        </xsd:restriction>
      </xsd:simpleType>
    </xsd:element>
    <xsd:element name="Severity" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:simpleType>
        <xsd:restriction base="xsd:integer">
          <xsd:minInclusive value="0" />
          <xsd:maxInclusive value="2" />
        </xsd:restriction>
      </xsd:simpleType>
    </xsd:element>
    <xsd:element name="ManagedEntityTypeId" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    <xsd:element name="KeyProperties" type="System.ManagedEntityKeys" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    <xsd:element name="AlertName" type="xsd:string" minOccurs="0" maxOccurs="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    <xsd:element name="AlertDescription" type="xsd:string" minOccurs="0" maxOccurs="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    <xsd:element name="AlertOwner" type="xsd:string" minOccurs="0" maxOccurs="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    <xsd:element name="AlertMessageId" type="xsd:string" minOccurs="0" maxOccurs="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    <xsd:element name="AlertParameters" type="System.Health.AlertParameters" minOccurs="0" maxOccurs="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    <xsd:element name="Suppression" type="System.Health.Suppression" minOccurs="0" maxOccurs="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    <xsd:element name="Custom1" type="xsd:string" minOccurs="0" maxOccurs="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    <xsd:element name="Custom2" type="xsd:string" minOccurs="0" maxOccurs="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    <xsd:element name="Custom3" type="xsd:string" minOccurs="0" maxOccurs="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    <xsd:element name="Custom4" type="xsd:string" minOccurs="0" maxOccurs="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    <xsd:element name="Custom5" type="xsd:string" minOccurs="0" maxOccurs="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    <xsd:element name="Custom6" type="xsd:string" minOccurs="0" maxOccurs="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    <xsd:element name="Custom7" type="xsd:string" minOccurs="0" maxOccurs="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    <xsd:element name="Custom8" type="xsd:string" minOccurs="0" maxOccurs="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    <xsd:element name="Custom9" type="xsd:string" minOccurs="0" maxOccurs="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    <xsd:element name="Custom10" type="xsd:string" minOccurs="0" maxOccurs="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
  </Configuration>
  <OverrideableParameters>
    <OverrideableParameter ID="Priority" Selector="$Config/Priority$" ParameterType="int" />
    <OverrideableParameter ID="Severity" Selector="$Config/Severity$" ParameterType="int" />
  </OverrideableParameters>
  <ModuleImplementation Isolation="Any">
    <Composite>
      <MemberModules>
        <ConditionDetection ID="Mapper" TypeID="System.Health.GenericAlertForTypeMapper">
          <Priority>$Config/Priority$</Priority>
          <Severity>$Config/Severity$</Severity>
          <ManagedEntityTypeId>$Config/ManagedEntityTypeId$</ManagedEntityTypeId>
          <KeyProperties>$Config/KeyProperties$</KeyProperties>
          <AlertName>$Config/AlertName$</AlertName>
          <AlertDescription>$Config/AlertDescription$</AlertDescription>
          <AlertOwner>$Config/AlertOwner$</AlertOwner>
          <AlertMessageId>$Config/AlertMessageId$</AlertMessageId>
          <AlertParameters>$Config/AlertParameters$</AlertParameters>
          <Suppression>$Config/Suppression$</Suppression>
          <WorkflowId>$MPElement$</WorkflowId>
          <Custom1>$Config/Custom1$</Custom1>
          <Custom2>$Config/Custom2$</Custom2>
          <Custom3>$Config/Custom3$</Custom3>
          <Custom4>$Config/Custom4$</Custom4>
          <Custom5>$Config/Custom5$</Custom5>
          <Custom6>$Config/Custom6$</Custom6>
          <Custom7>$Config/Custom7$</Custom7>
          <Custom8>$Config/Custom8$</Custom8>
          <Custom9>$Config/Custom9$</Custom9>
          <Custom10>$Config/Custom10$</Custom10>
          <ManagementGroupName>$Target/ManagementGroup/Name$</ManagementGroupName>
        </ConditionDetection>
        <WriteAction ID="WA" TypeID="System.Health.PublishAlert" />
      </MemberModules>
      <Composition>
        <Node ID="WA">
          <Node ID="Mapper" />
        </Node>
      </Composition>
    </Composite>
  </ModuleImplementation>
  <InputType>System!System.BaseData</InputType>
</WriteActionModuleType>

Parameters

The System.Health.GenerateAlertForType module supports the following configuration parameters.

Parameter Type Description

Priority

Integer

Required parameter. Specifies the priority (low, medium, high) for the alert. Acceptable values are between 0 and 2.

Severity

Integer

Required parameter. Contains severity (information, warning, error) for the alert. Acceptable values are between 0 and 2.

ManagedEntityTypeId

String

Required parameter. The ID of the class for which the alert is being created.

KeyProperties

String

Required parameter. Values for the key properties of the object for which the alert is being created.

AlertName

String

Optional parameter. Deprecated – use AlertMessageId instead.

AlertDescription

String

Optional parameter. Deprecated – use AlertMessageId instead.

AlertOwner

String

Optional parameter. Contains the owner for the alert. This parameter sets the initial owner, but it can be changed by a user when the alert is generated.

AlertMessageId

String

Optional parameter. Specifies the ID for the alert message in the StringResources section of the management pack.

AlertParameters

System.Health.AlertParameters

Contains up to 10 alert parameters that are used to populate the alert description.

Suppression

System.Health.Suppression

Defines how multiple alerts from the same rule are suppressed.

Custom1

String

Specifies the value for custom alert field 1.

Custom2

String

Specifies the value for custom alert field 2.

Custom3

String

Specifies the value for custom alert field 3.

Custom4

String

Specifies the value for custom alert field 4.

Custom5

String

Specifies the value for custom alert field 5.

Custom6

String

Specifies the value for custom alert field 6.

Custom7

String

Specifies the value for custom alert field 7.

Custom8

String

Specifies the value for custom alert field 8.

Custom9

String

Specifies the value for custom alert field 9.

Custom10

String

Specifies the value for custom alert field 10.

For more information about the parameters used by this module, see System.Health.GenerateAlert.

Composition

The System.Health.GenerateAlertForType module is a composite module that contains the member modules that are described in the following table.

Workflow Run Order Module Type Usage

1

System.Health.GenericAlertForTypeMapper

Maps the incoming data to an alert data type for a specific type.

2

System.Health.PublishAlert

Writes the alert to the Operations Manager database.

Remarks

Take caution when using this module, because you cannot verify that the object you are creating the alert for actually exists. If you attempt to create an alert for an object that doesn’t exist, you will receive an error alert. In addition, it may be difficult to determine the key properties of the object for which you are creating the alert. You will typically need to get these values from a data variable such as from the property bag in a script being used for the data source or the values of event parameters.

Module Type Usage

System.Health.GenerateAlert

Generates an alert for the type that is the target of the rule or monitor.

External Module References

None

Sample

The following example illustrates a rule that uses System.Health.GenerateAlertForType. The target of the rule is Class1, but the alert is raised on an instance of Class2. The script used in the data source provides a property bag that contains the key property of the Class2 object. This value is used to create the alert on that object.

<Rule ID="MPAuthor.Relationship.AlertForClass2" Enabled="true" Target="MPAuthor.Relationship.Class1" ConfirmDelivery="true" Remotable="true" Priority="Normal" DiscardLevel="100">
  <Category>Custom</Category>
  <DataSources>
    <DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.PropertyBagProvider">
      <IntervalSeconds>60</IntervalSeconds>
      <SyncTime />
      <ScriptName>PerfCounter.vbs</ScriptName>
      <Arguments>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Arguments>
      <ScriptBody><![CDATA[
      sComputerName = WScript.Arguments(0)            
            
      Set oAPI = CreateObject("MOM.ScriptAPI")
      Set oBag = oAPI.CreatePropertyBag()

      Call oBag.AddValue("PerfValue",10)
      Call oBag.AddValue("ObjectName","Object3")
      Call oBag.AddValue("ComputerName",sComputerName)
  
      oAPI.Return(oBag)
  ]]></ScriptBody>
      <TimeoutSeconds>60</TimeoutSeconds>
    </DataSource>
  </DataSources>
  <ConditionDetection ID="FilterPerf" TypeID="System!System.ExpressionFilter">
    <Expression>
      <SimpleExpression>
        <ValueExpression>
          <XPathQuery Type="Integer">Property[@Name="PerfValue"]</XPathQuery>
        </ValueExpression>
        <Operator>Greater</Operator>
        <ValueExpression>
          <Value Type="Integer">5</Value>
        </ValueExpression>
      </SimpleExpression>
    </Expression>
  </ConditionDetection>
  <WriteActions>
    <WriteAction ID="GenerateAlert" TypeID="Health!System.Health.GenerateAlertForType">
      <Priority>1</Priority>
      <Severity>2</Severity>
      <ManagedEntityTypeId>$MPElement[Name="MPAuthor.Relationship.Class2"]$</ManagedEntityTypeId>
      <KeyProperties>
        <KeyProperty>
          <PropertyId>$MPElement[Name="MPAuthor.Relationship.Class2"]/Name$</PropertyId>
          <IsCaseSensitive>false</IsCaseSensitive>
          <Value>$Data/Property[@Name="ObjectName"]$</Value>
        </KeyProperty>
        <KeyProperty>
          <PropertyId>$MPElement[Name="Windows!Microsoft.Windows.Computer"]/PrincipalName$</PropertyId>
          <IsCaseSensitive>false</IsCaseSensitive>
          <Value>$Data/Property[@Name="ComputerName"]$</Value>
        </KeyProperty>
      </KeyProperties>
      <AlertName />
      <AlertDescription />
      <AlertOwner />
      <AlertMessageId>$MPElement[Name="MPAuthor.Relationship.AlertForClass2.AlertMessage"]$</AlertMessageId>
      <AlertParameters>
        <AlertParameter1>$Data/EventDescription$</AlertParameter1>
      </AlertParameters>
      <Suppression />
      <Custom1 />
      <Custom2 />
      <Custom3 />
      <Custom4 />
      <Custom5 />
      <Custom6 />
      <Custom7 />
      <Custom8 />
      <Custom9 />
      <Custom10 />
    </WriteAction>
  </WriteActions>
</Rule>

Information

   

Module Type

WriteActionModuleType

Input Type

System.BaseData

Output Type

None

Implementation

Composite

Library

System.Health.Library