How to create a monitor based on a custom module

Applies To: System Center Operations Manager 2007

Note

This exercise has been updated to include a procedure for Visual Studio Authoring Extensions in the latest version of the Management Pack Authoring Guide on the TechNet Wiki.

The following procedure shows how to create a monitor based on a custom data source module running a script using 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 class to act as the target.

The monitor has the following characteristics:

  • Targeted at a class with only a single instance on an agent. Because there is a single instance, there is no requirement to support cookdown.

  • Sets its state based on the comparison of the script value to specified threshold values.

  • The monitor supports On Demand Discovery. This requires a probe action module to run the script.

  • The script accepts only a single argument for the computer name of the target object’s agent.

  • The script itself is only for testing and performs no real function. It simulates a script running a synthetic transaction and returning a status message of success or failure.

To create probe action module to run a script

  1. Select Type Library and then Probe Actions.

  2. Right-click in the Probe Actions pane and select New and then Composite Probe Action.

  3. In the Choose a unique identifier box, type MyMP.ProbeActionModule.MyTransactionScript. Click OK.

  4. On the General tab, in the Name box, type Transaction Script Probe Action.

  5. On the Member Modules tab, do the following:

    1. Click Add to add a module.

    2. In the Choose Module Type box, select Microsoft.Windows.ScriptPropertyBagProbe.

    3. In the Module ID box, type Script. Click OK.

    4. In the ScriptName box, type MyTransactionScript.vbs.

    5. In the Arguments box, type $Config/ComputerName$.

    6. In the TimeoutSeconds box, type 300.

    7. Click the Edit… button. This starts the custom editor.

    8. Paste the complete contents of the following script between the ScriptBody tags in the XML. Replace any text that might already exist.

      <![CDATA[
      sComputerName = WScript.Arguments(0)
      bTestSuccessful = True
      
      Set oAPI = CreateObject("MOM.ScriptAPI")
      oAPI.LogScriptEvent "MyTransactionScript.vbs",10,4, "Running script on " & sComputerName
      Set oBag = oAPI.CreatePropertyBag()
      Call oBag.AddValue("ComputerName",sComputerName)
      If bTestSuccessful = True Then
      Call oBag.AddValue("Result","Good")
      Else
      Call oBag.AddValue("Result","Bad")
      End If
      oAPI.Return(oBag)
      ]]>
      
    9. Close the editor to save the script back to the module.

    10. Click OK to save the module configuration.

    11. In the NextModule column for the Script module, select Module Output.

  6. On the Configuration Schema tab, do the following:

    1. In the Simple Configuration Schema section, click Add to add a parameter.

    2. In the Please enter the requested value box, type ComputerName. Click OK.

  7. On the Data Types tab, do the following:

    1. In the Input Data section, select This module required input data.

    2. In the Output Data section, in the Data Type: box select System.PropertyBagData.

  8. Click OK to save the module.

  9. Select File, and then click Save.

To create data source module to run probe action on schedule

  1. Select Type Library and then Data Sources.

  2. Right-click the Data Sources pane, select New, and then Composite Data Source.

  3. In the Choose a unique identifier box, type MyMP.DataSourceModule.MyTransactionScriptTimed. Click OK.

  4. On the General tab, in the Name box, type Timed Transaction Script Data Source

  5. On the Member Modules tab, do the following:

    1. Click Add to add a module.

    2. In the Choose Module Type box, select System.SimpleScheduler.

    3. In the Module ID box, type Schedule. Click OK.

    4. Click the button to the right side of the IntervalSeconds box and select Promote. This enters the text $Config/IntervalSeconds$

    5. Click the button to the right side of the SyncTime box and select Promote. This enters the text $Config/SyncTime$

    6. Click OK to save the module configuration.

    7. Click Add to add a new module.

    8. In the Choose Module Type box, select MyMP.ProbeActionModule.MyTransactionScript.

    9. In the Module ID box, type Probe. Click OK.

    10. Select the button to the right side of the ComputerName box and select Promote. This enters the text $Config/ComputerName$.

    11. Click OK to save the module configuration.

    12. In the NextModule column for the Schedule module, select Probe.

    13. In the NextModule column for the Probe module, select Module Output.

  6. On the Configuration Schema tab, do the following:

    1. Change the Type for the IntervalSeconds parameter to Integer.

    2. Clear the Required box next to the SyncTime parameter. The SyncTime parameter is optional for this module.

  7. On the Overrideable Parameters tab, do the following:

    1. Click Add and then IntervalSeconds.

    2. In the Choose a unique identifier box, type IntervalSeconds. Click OK.

    3. Change Configuration Element to Integer.

    4. Click Add and then SyncTime.

    5. In the Choose a unique identifier box, type SyncTime. Click OK.

  8. On the Data Types tab ensure the value in the Data Types box is System.PropertyBagData.

  9. Click OK to save the module.

  10. Select File, and then click Save.

To create monitor type using custom data source

  1. Select Type Library and then Monitor Types.

  2. Right-click in the Monitor Types pane and select New and then Composite Monitor Type.

  3. In the Choose a unique identifier box, type MyMP.MyTransactionMonitorType. Click OK.

  4. On the General tab, in the Name box, type My Transaction Script Monitor Type.

  5. On the States tab, do the following:

    1. Select 2 State Monitor Type.

    2. In the ID of state 1 box type Success.

    3. In the ID of state 2 box, type Failure.

  6. On the Member Modules tab, do the following:

    1. Click Add to add a module.

    2. In the Choose Module Type box, select System.PassThroughProbe.

    3. In the Module ID box, type PassThru. Click OK.

    4. Click OK to save the module configuration.

    5. Click Add to add a module.

    6. In the Choose Module Type box, select MyMP.ProbeActionModule.MyTransactionScript.

    7. In the Module ID box, type Probe. Click OK.

    8. Click the button to the right of the ComputerName box and select Promote. This will enter the text $Config/ComputerName$

    9. Click OK to save the module configuration.

    10. Click Add to add a new module.

    11. In the Choose Module Type box, select MyMP.DataSourceModule.MyTransactionScriptTimed.

    12. In the Module ID box, type DataSource. Click OK.

    13. Click the button to the right side of the IntervalSeconds box and select Promote . This enters the text $Config/IntervalSeconds$

    14. Click the button to the right side of the ComputerName box and select Promote. This enters the text $Config/ComputerName$

    15. Note

      The SyncTime parameter must be added manually with an XML editor. This is because the Authoring console only populates the Configuration dialog box with required parameters for the selected module. The SyncTime parameter was configured to not be required.

      Click Edit. This starts the custom editor.

    16. After the line

      <IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
      

      Add the following line

      <SyncTime>$Config/SyncTime$</SyncTime>
      
    17. Close the editor to add the XML back the Authoring console.

      Note

      If you receive an error saying that the IntervalSeconds parameter is invalid according to its data type, click Ignore. This error message occurs because the IntervalSeconds parameter is configured as an integer, and the Authoring Console is reading $Config/IntervalSeconds$ as a string. This variable will be replaced with an integer value when the workflow is run so the error can be ignored.

    18. Click OK to save the module configuration.

    19. Click Add to add a new module.

    20. In the Choose Module Type box, select System.ExpressionFilter.

    21. In the Module ID box, type FilterSuccess. Click OK.

    22. Click Configure to open the Expression dialog box.

    23. Click Insert.

    24. In the Parameter Name box type Property[@Name='Result'].

    25. In the Operator box select Equals.

    26. In the Value box type Good.

    27. Click OK to save the expression.

    28. Click OK to save the module configuration.

    29. Click Add to add a new module.

    30. In the Choose Module Type box, select System.ExpressionFilter.

    31. In the Module ID box, type FilterFailure. Click OK.

    32. Click Configure to open the Expression dialog box.

    33. Click Insert.

    34. In the Parameter Name box type Property[@Name='Result'].

    35. In the Operator box select Equals.

    36. In the Value box type Bad.

    37. Click OK to save the expression.

    38. Click OK to save the module configuration.

  7. On the Regular tab, do the following:

    1. Select Success.

    2. Check the Include box next to DataSource.

    3. Check the Include box next to FilterSuccess.

    4. In the Next Module box next to DataSource select FilterSuccess.

    5. In the Next Module box next to FilterSuccess select Monitor State Output.

    6. Select Failure.

    7. Check the Include box next to DataSource.

    8. Check the Include box next to FilterFailure.

    9. In the Next Module box next to DataSource select FilterFailure.

    10. In the Next Module box next to FilterFailure select Monitor State Output.

  8. On the On Demand tab, do the following:

    1. Check the box next to Use On Demand Detection.

    2. Select Success.

    3. Check the Include box next to PassThru.

    4. Check the Include box next to Probe.

    5. Check the Include box next to FilterSuccess.

    6. In the Next Module box next to PassThru select Probe.

    7. In the Next Module box next to Probe select FilterSuccess.

    8. In the Next Module box next to FilterSuccess select Monitor State Output.

    9. Select Failure.

    10. Check the Include box next to PassThru.

    11. Check the Include box next to Probe.

    12. Check the Include box next to FilterFailure.

    13. In the Next Module box next to PassThru select Probe.

    14. In the Next Module box next to Probe select FilterFailure.

    15. In the Next Module box next to FilterFailure select Monitor State Output.

  9. On the Configuration Schema tab, do the following:

    1. In the Type box next to IntervalSeconds select Integer.

    2. Click Add to add a parameter.

    3. In the Please enter the requested value box type SyncTime. Click OK.

    4. Clear the Required box next to SyncTime.

  10. On the Overrideable Parameters tab, do the following:

    1. Click Add, then IntervalSeconds.

    2. In the Choose a unique identifier box type IntervalSeconds. Click OK.

    3. In the Configuration Element box for IntervalSeconds, select Integer.

    4. Click Add, then SyncTime.

    5. In the Choose a unique identifier box, type SyncTime. Click OK.

  11. Click OK to save the module type.

  12. Select File, then click Save.

To create monitor based on custom monitor type

  1. Select Health Model, then Monitors.

  2. In the Monitors pane, expand MyMP.MyComputerRole1 and System.Health.EntityState.

  3. Right-click System.Health.AvailabilityState, select New, and then Custom Unit Monitor.

  4. In the Choose a unique identifier box, type MyMP.MyTransactionMonitor. Click OK.

  5. On the General tab, in the Name box, type My Transaction Monitor.

  6. On the Configuration tab, do the following:

    1. Click Browse for a type.

    2. In the Choose unit monitor type box, select MyMP.MyTransactionMonitorType. Click OK.

    3. In the IntervalSeconds box type 900.

    4. Clear the text in the ComputerName box. Click the button to the right side of the box, select (Host=Windows Computer), and then Principal Name (Windows Computer).

  7. On the Health tab, do the following:

    1. In the Health State box for Success select Healthy.

    2. In the Health State box for Failure select Critical.

  8. On the Alerting tab, do the following:

    1. Check the box next to Generate alerts for this monitor.

    2. In the Generate an alert when, select The monitor is in a critical or warning health state.

    3. In the Alert name: box, type Test transaction failed.

  9. Click OK to save the monitor.

  10. Select File, then click Save.