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:
- Creating a New Management Pack - Create the management pack.
- Creating a Class - Create the class to be discovered.
- Creating a Registry Discovery - Create the discovery template group. (VSAE only)
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
- Select Health Model, and then select Discoveries.
- Right-click in the right-side pane, select New, and then select WMI.
- On the General page, do the following:
- In the Element ID box, type MyMP.Discovery.MyComputerRole2.
- In the Display Name box, type Discover Computer Role 2.
- In the Target box, select MyMP.MyComputerRole1.
- In the Category box, select Discovery, and then click Next.
- On the WMI Configuration page, do the following:
- In the WMI Namespace box, type root\cimv2.
- In the Query box, type select name, version from cim_datafile where name ='c:\MyApp\MyApp.exe'.
- In the Frequency (seconds) box, type 14400. Click Next.
- On the Discovery Mapper page, do the following:
- In the Class ID box, select MyMP.ComputerRole2.
- 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.
- 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.
- 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).
- Click Finish.
- Select File, and then click Save.
Visual Studio Authoring Extensions Procedure
Create the Discovery:
- In Solution Explorer, right click Right click Discoveries.mptg and click Open.
- Right click in the template window and select Add Template.
- Select Discovery (Custom) and click OK.
Configure the Discovery Properties:
- Right click the entry for NewDiscovery and select Properties Window.
- Change the ID to Discovery.MyComputerRole2.
- Change the Display Name to Discover Computer Role 2.
Select the Discovery Target:
- Select Target and click the ellipse (...) button on the right of the field.
- Select MyMP.MyComputerRole1 and click OK.
Select and Configure the Discovery Data Source"
Select Data Source Type ID and click the ellipse (...) button on the right of the field.
Select Microsoft.Windows.WmiProviderWithClassSnapshotDataMapper and click OK.
Select Data Source Configuration and click the ellipse (...) button on the right of the field.
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>
Save and Compile the Project:
- Select File, and then click Save Discoveries.mptg.
- Select Build and then Build Solution.
- Ensure that you don't receive any errors.