다음을 통해 공유


Management Pack Service Model Exercise #5 - Creating a WMI Discovery


Overview

The following procedures show how to create a Windows Management Instrumentation (WMI) discovery using  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 WMI discovery created in this procedure has the following characteristics:

  • Searches for the application on all computers that have an instance of MyComputerRole1.
  • Discovers a class named MyComputerRole2. The class has a single non-key property named Version and no key property.
  • An instance of the class should only be created if a file named C:\MyApp\MyApp.exe exists.
  • If a class is created, the version should be collected from the version property on the file.

Authoring Console Procedure

  1. Select Health Model, and then select Discoveries.
  2. Right-click in the right-side pane, select New, and then select WMI.
  3. On the General page, do the following:
    1. In the Element ID box, type MyMP.Discovery.MyComputerRole2.
    2. In the Display Name box, type Discover Computer Role 2.
    3. In the Target box, select MyMP.MyComputerRole1.
    4. In the Category box, select Discovery, and then click Next.
  4. On the WMI Configuration page, do the following:
    1. In the WMI Namespace box, type root\cimv2.
    2. In the Query box, type select name, version from cim_datafile where name ='c:\MyApp\MyApp.exe'.
    3. In the Frequency (seconds) box, type 14400. Click Next.
  5. On the Discovery Mapper page, do the following:
    1. In the Class ID box, select MyMP.ComputerRole2.
    2. In the Key Properties section, click the button to the right side 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/Property[@Name='Version']$. This step uses a $Data variable to resolve to the data returned from the WMI query. 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.
  6. Select File, and then click Save.

Visual Studio Authoring Extensions Procedure

  1. Create the Discovery:

    1. In Solution Explorer, right click Right click Discoveries.mptg and click Open.
    2. Right click in the  template window and select Add Template.
    3. Select Discovery (Custom) and click OK.
  2. Configure the Discovery Properties:

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

    1. Select Target and click the ellipse (...) button on the right of the field. 
    2. Select MyMP.MyComputerRole1 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.WmiProviderWithClassSnapshotDataMapper 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.

      <!-- Namespace identifies the WMI namespace containing the class being queried. -->
      <NameSpace>root\cimv2</NameSpace>
      <!-- Query is the WQL query to run. -->
      <Query>select name, version from cim_datafile where name ='c:\\MyApp\\MyApp.exe'</Query>
      <!-- Frequency specifies how often we will run the discovery. -->
      <Frequency>14400</Frequency>
      <!-- Class ID specifies the class that we are discovering. -->
      <ClassId>$MPElement[Name="MyMP.MyComputerRole2"]$</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/Property[@Name='Version']$</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>
      
  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