How to create a script-based performance collection rule

適用於: System Center Operations Manager 2007

The following procedure shows how to create a performance 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 performance 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 Performance Based, and then select Script Based Performance Collection.

  3. On the General page, do the following:

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

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

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

    4. In the Category box, select PerformanceCollection. 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 MyPerfCollectionScript.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("InstanceName","MyInstance")
      Call oBag.AddValue("Value",10)
      
      oAPI.Return(oBag)
      
    4. Click the Parameters button.

    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 Performance Mapper page, do the following:

    1. In the Object box type MyApp.

    2. In the Counter box type MyCounter.

    3. In the Instance box type $Data/Property[@Name=’InstanceName’]$.

    4. In the Value box type $Data/Property[@Name=’Value’]$.

    5. Click Finish.

另請參閱

概念

Monitoring Scripts
Performance Collection Rules