How to Create a Script Discovery

適用於: System Center Operations Manager 2007

The following procedure shows how to create a script discovery in the Operations Manager 2007 Authoring console. Before you perform this procedure, you must first complete the prerequisite procedure How to Create a Class in which you create the classes to be discovered.

The discovery created in this procedure has the following characteristics:

  • Searches for class on any agent with an instance of MyComputerRole1.

  • Discovers three instances of a class named My Application Component. The class has a single key property called ComponentName and a non-key property named Version.

  • The discovered class is hosted by a class named MyComputerRole1 which is hosted by the Windows Computer class. This hosting class has no key property.

To create a script discovery

  1. Select Health Model, and then select Discoveries.

  2. Right-click in the Discoveries pane, select New, and then select Script.

  3. On the General page, do the following:

    1. In the ElementID box, type MyMP.Discovery.MyApplicationComponent.

    2. In the Display Name box, type Discover MyApplicationComponent.

    3. In the Target box, select MyMP.MyComputerRole1.

    4. In the Category box, select Discovery. Click Next.

  4. On the Schedule page, in the Run every: box, type 4 hours. Click Next.

  5. On the Script page, do the following:

    1. In the File Name box, type DiscoverApplicationComponents.vbs.

    2. In the Timeout box, type 5 minutes.

    3. Copy the complete following script, and paste it into the Script box.

      SourceId = WScript.Arguments(0) 
      ManagedEntityId = WScript.Arguments(1)
      sComputerName = WScript.Arguments(2)
      
      Set oAPI = CreateObject("MOM.ScriptAPI")
      Set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
      
      For i = 1 to 3
         Set oInstance = oDiscoveryData.CreateClassInstance("$MPElement[Name='MyMP.MyApplicationComponent']$")
         oInstance.AddProperty "$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", sComputerName
         oInstance.AddProperty "$MPElement[Name='MyMP.MyApplicationComponent']/ComponentName$", "Component" & i
         oDiscoveryData.AddInstance(oInstance)
      Next
      oAPI.Return(oDiscoveryData)
      
    4. Click Parameters.

    5. In the Parameters box, type $MPElement$, followed by a space.

    6. Click Target, and select Id.

    7. Type a space after $Target/Id$.

    8. Click Target, select (Host=Windows Computer), and then select Principal Name (Windows Computer). Make sure that there is a space between the three variables in the Parameters box.

    9. Click OK, and then click Finish.

  6. Select File, and then click Save.