Share via


Management Pack Service Model Exercise #4 - Creating a Registry Discovery


Overview

The following procedure shows how to create a registry discovery using both the Operations Manager 2007 Authoring console and Visual Studio Authoring Extensions. 

Product Versions

This exercise applies to the following products:

  • System Center Operations Manager 2007 R2
  • System Center 2012 Operations Manager
  • System Center 2012 Operations Manager SP1

Prerequisites

Before you perform this procedure, you must first complete the following prerequisite procedures:

Revisions

The Microsoft System Center team has validated this procedure as of the original version.  We will continue to review any changes and periodically provide validations on later revisions as they are made.  Please feel free to make any corrections or additions to this procedure that you think would assist other users

Details

The registry discovery created in this procedure has the following characteristics:

  • Searches for the application on all computers.
  • Discovers a class named MyComputerRole1. The class has a single non-key property named Version and has no key property.
  • An instance of the class should only be created if a registry key named HKLM:\SOFTWARE\MyApp exists.
  • If a class is created, the version should be collected from the value HKLM:\SOFTWARE\MyApp\Version.

Authoring Console Procedure

  1. Select Health Model, and then select Discoveries.
  2. Right-click in the right-side pane, select New, and then select Registry Filtered.
  3. On the General page, do the following:
    1. In the Element ID box, type MyMP.Discovery.MyComputerRole1.
    2. In the Display Name box, type Discover Computer Role 1.
    3. In the Target box, select Browse all classes.
    4. In the Management Pack Class Chooser box, select Microsoft.Windows.OperatingSystem, and then click OK.
    5. In the Category box, select Discovery, and then click Next.
    6. Click Next.
  4. On the Schedule page in the Run every box, select 1 Hours, and then click Next. Do not select the box Synchronize at: box
  5. On the Computer page, notice that the Computer box should already contain the following required text: $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$. If it does not, instead of typing the text, fill it in by selecting the button to the right side of the Computer box, selecting (Host=Windows Computer), and then selecting Network Name (Windows Computer). Click Next. This option specifies the name of the computer on which the registry will be searched. The $Target variable specified refers to the network name of the computer that is hosting the target operating system object.
  6. On the Registry Probe Configuration page, do the following:
    1. Click Add.
    2. In the Edit Attribute Properties dialog box, select Key for the Object Type.
    3. In the Name box, type AppExists.
    4. In the Path box, type SOFTWARE\MyApp.
    5. In the Attribute Type box, select Check if exists. Click OK.
    6. Click Add.
    7. In the Edit Attribute Properties dialog box, select Value for the Object Type.
    8. In the Name box, type AppVersion. In the Path box, type SOFTWARE\MyApp\Version.
    9. In the Attribute Type box, select String. Click OK.
    10. Click Next.
  7. On the Build Event Expression page, do the following:
    1. Click Insert.
    2. Click the button to the right side of the Parameter Name box, and then select AppExists.
    3. In the Operator box, select Equals.
    4. In the Value box, type True.
    5. Click Next.
  8. On the Discovery Mapper page, do the following:
    1. In the Class ID box, select MyMP.ComputerRole1.
    2. In the Key Properties section, click the button to the right of the Value for Microsoft.Windows.Computer/PrincipalName, select (Host=Windows Computer), and then select Principal Name (Windows Computer). This step fills in the following text for the value: $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName. This is a $Target variable that resolves to the computer name of the target agent.
    3. In the Non-Key Properties section, in the Value for MyMP.MyComputerRoleBase\Version, type $Data/Values/AppVersion$. This step uses a $Data variable to resolve to the data that is stored in the Version registry value that is defined on the Registry Probe Configuration page. It cannot be selected from a menu because the menu can only prompt for $Target variables.
    4. Click the button to the right side of the Value for System.Entity/DisplayName, select (Host=Windows Computer), and then select Principal Name (Windows Computer).
    5. Click Finish.
  9. Select File, and then click Save.

Visual Studio Authoring Extensions Procedure

  1. Create the Discovery:

    1. Right click the name of the solution and select Add and then New Item
    2. Select Discovery.
    3. In the Name box, type Discoveries.mptg and click Add.
  2. Configure the Discovery Properties:

    1. Right click the entry for NewDiscovery and select Properties Window.
    2. Change the ID to Discovery.MyComputerRole1.
    3. Change the Display Name to Discover Computer Role 1.
  3. Select the Discovery Target:

    1. Select Target and click the ellipse (...) button on the right of the field. 
    2. Select Microsoft.Windows.OperatingSystem and click OK.
  4. Select and Configure the Discovery Data Source"

    1. Select Data Source Type ID and click the ellipse (...) button on the right of the field. 

    2. Select Microsoft.Windows.FilteredRegistryDiscoveryProvider and click OK.

    3. Select Data Source Configuration and click the ellipse (...) button on the right of the field.

    4. Copy the following XML into the configuration window between the <Configuration> tags.  Note that you can use Intellisense to manually type in each entry.

        <!-- Computer Name specifies the computer with the registry to check.  We will use a variable for the local computer. -->
        <ComputerName>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ComputerName>
      
      
        <!-- Registry Attribute Definitions specify which keys and values we want from the registry. -->
        <RegistryAttributeDefinitions>
          <RegistryAttributeDefinition>
            <AttributeName>AppExists</AttributeName>
            <Path>SOFTWARE\MyApp</Path>
            <PathType>0</PathType>
            <AttributeType>0</AttributeType>
          </RegistryAttributeDefinition>
          <RegistryAttributeDefinition>
            <AttributeName>AppVersion</AttributeName>
            <Path>SOFTWARE\MyApp\MyVersion</Path>
            <PathType>1</PathType>
            <AttributeType>1</AttributeType>
          </RegistryAttributeDefinition>
        </RegistryAttributeDefinitions>
      
      
        <!-- Frequency specifies how often we will run the discovery. -->
        <Frequency>3600</Frequency>
      
      
        <!-- Class ID specifies the class that we are discovering. -->
        <ClassId>$MPElement[Name="MyMP.MyComputerRole1"]$</ClassId>
      
      
        <!-- Instance Settings specify the values to use for different properties of the discovered class. -->
        <InstanceSettings>
          <Settings>
            <Setting>
              <Name>$MPElement[Name="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Name>
              <Value>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Value>
            </Setting>
            <Setting>
              <Name>$MPElement[Name="MyMP.MyComputerRoleBase"]/Version$</Name>
              <Value>$Data/Values/AppVersion$</Value>
            </Setting>
            <Setting>
              <Name>$MPElement[Name="System!System.Entity"]/DisplayName$</Name>
              <Value>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Value>
            </Setting>
          </Settings>
        </InstanceSettings>
      
      
        <!-- Expression specifies the criteria that must be true for the instance to be created. -->
        <Expression>
          <SimpleExpression>
            <ValueExpression>
              <XPathQuery Type="String">Values/AppExists</XPathQuery>
            </ValueExpression>
            <Operator>Equal</Operator>
            <ValueExpression>
              <Value Type="String">True</Value>
            </ValueExpression>
          </SimpleExpression>
        </Expression>
      
  5. Save and Compile the Project:

    1. Select File, and then click Save Discoveries.mptg.
    2. Select Build and then Build Solution.
    3. Ensure that you don't receive any errors.

See Also