How to create a script-based event collection rule

適用於: System Center Operations Manager 2007

The following procedure shows how to create an event collection rule by using a monitoring script 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 target class.

The monitor created in this procedure has the following characteristics:

  • Runs on any computer that has an instance of MyComputerRole1.

  • The script accepts two parameters, one for computer name and another for the version of the application that is stored as a property on the target class.

  • The script itself is only for testing and performs no real function. It simulates a script running a synthetic transaction and returning a property bag with static values.

To create a script based event collection rule

  1. In the Authoring console, select Health Model, and then select Rules.

  2. Right-click in the Rules pane, select New, select Collection, select Event Based, and then select Script Based Event Collection.

  3. On the General page, do the following:

    1. In the ElementID box, type MyMP.Rule.CollectScriptEvent.

    2. In the Display Name box, type My Application Collect Script Event.

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

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

  4. On the Schedule page, in the Run every box, type 15 minutes.

  5. On the Script page, do the following:

    1. For the File Name value, type MyEventCollectionScript.vbs

    2. For the Timeout value, type 1 minutes

    3. In the Script box, paste the complete contents of the following script.

      sComputerName = WScript.Arguments(0)
      sVersion = WScript.Arguments(1)
      
      Set oAPI = CreateObject("MOM.ScriptAPI")
      Set oBag = oAPI.CreatePropertyBag()
      Call oBag.AddValue("ComputerName",sComputerName)
      Call oBag.AddValue("EventID",100)
      Call oBag.AddValue("ParamValue","Param1")
      
      oAPI.Return(oBag)
      
    4. Click Parameters.

    5. Select Target, select (Host=Windows Computer), and then select Principal Name (Windows Computer).

    6. Type a SPACE.

    7. Select Target and then Version (My Computer Role Base).

    8. Click OK.

    9. Click Next.

  6. On the Event Mapper page, do the following:

    1. In the Computer box type $Data/Property[@Name='ComputerName']$.

    2. In the Event source box type MyApp.

    3. In the Event log box type CustomScript.

    4. In the Event ID box type $Data/Property[@Name='EventID']$.

    5. In the Category box type 0.

    6. In the Level box select Information.

    7. Click the Parameters button.

    8. Type $Data/Property[@Name='ParamValue']$

    9. Click OK.

    10. Click Finish.

另請參閱

概念

Monitoring Scripts
Event Collection Rules