Export (0) Print
Expand All

$Target

System Center

Updated: August 10, 2011

Applies To: Operations Manager 2007 R2, System Center Operations Manager 2007

The $Target variable notation refers to the targeted class type of a monitoring object and allows for runtime access of the targeted class type.

$Target/Host/Property[Type=” Name of class ”]/PropertyName$

Within an instance of a monitoring object, such as rule or a unit monitor, the $Target variable can retrieve data from its target class type. The target class type is the value of the Target attribute of an element that defines a Management Pack element type. For example, a rule that must groom a database nightly at midnight is targeted at the class that hosts the databases. When you create the rule that will groom the databases, you will not know the name of the SQL Server that hosts the database or even the names of the databases that must groomed. Therefore, you can use the $Target variable to retrieve this information at run time.

The $Target variable is also used in a type projection Component element to refer to the target of a relationship type definition.

 

Syntax Section Description

$Target

The name of the variable you need to use.

Type=ID of ClassType

The value of ID attribute of the class type that is the target of this Management Pack element. This can be the value of the Target attribute of this Management Pack element or a class that hosts the target of this Management Pack element.

Relationship=ID of RelationshipType

The value of ID attribute of the relationship type in the type projection element.

SeedRole=ID of RelationshipType

Defines what role the seed element should play in the relationship hierarchy in a type projection. Can be one of two values: “Target” or “Source”. If “Source” is specified, the SeedRole element is the source of the relationship. If “Target is specified, the SeedRole element is the target of the relationship.

TypeConstraint=ID of RelationshipType

The value of the ID attribute of a class type instance referred to in a type projection element. Used to restrict the element to class type derivations.

PropertyName

Name of the property whose value you want to retrieve.

Host

Use if the class type in the class name section is the host of the target class.

Property

Use if you are naming a property of the class type named in the class name section.

Path

Use if you are referring to the target of a relationship type definition in a type projection definition.

The following example instructs Operations Manager to find the FQDN, which is the value of the NetworkName property, for each instance of the target class of the monitoring object you are creating.

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

The following example retrieves the value of the NetworkName property for all instances of the class that hosts the target class. The hosting class is the Computer class that is defined in the Microsoft Windows Library.

$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$

You can retrieve a property value from a class all the way up the hosting tree. You specify how high to go simply by adding another host. For example, if you wanted a value from a computer class that hosts a server class that hosts a database server class that hosts the database, use the following syntax:

$Target/Host/Host/Host/Property

If the discovery is targeted at a class hosted two levels above the computer, the Host section of the syntax must be specified twice, as in $Target/Host/Host. Use the following syntax to retrieve the value of the NetworkName property from the hosting class that is two levels above the current class:

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

The value retrieved by the $Target variable can also be appended to text. The following syntax prepends SqlServer to the name of each instance of a discovered object:

 <InstanceName>SqlServer$Target/Property/SQLInstanceName$</InstanceName>

The final sample illustrates how to refer to a relationship path within a hierarchy tree for a type projection element. In this case, each target notation refers to the Target element in the specified relationship. For the Reviewer element, the relationship type is the System.ReviewActivityHasReviewer relationship type of which System.Reviewer is the target. For the User element, the relationship type is the System.ReviewerIsUser relationship type of which System.User is the target.


<TypeProjection ID="System.WorkItem.Activity.ReviewActivityViewProjection" Accessibility="Public" Type="CoreActivity!System.WorkItem.Activity.ReviewActivity">
  <Component Alias="Reviewer" Path="$Target/Path[Relationship='CoreActivity!System.ReviewActivityHasReviewer']$">
    <Component Alias="User" Path="$Target/Path[Relationship='CoreActivity!System.ReviewerIsUser']$" />
  </Component>
</TypeProjection>

 
Show:
© 2014 Microsoft