This document is part of the Operations Manager Management Pack Authoring Guide


Table of Contents




Overview

The following procedure shows how to create a monitor and rule based on a common data source module using the Operations Manager 2007 Authoring console and Visual Studio Authoring Extensions. 

Product Versions

This exercise applies to the following products:

Prerequisites

Before you perform this procedure, you must first complete the following prerequisite procedures:

Revisions

The Microsoft System Center team has validated this procedure as of the original revision.  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

Sample Code

A sample of the completed code for each exercise is available in the TechNet Gallery.  There is a separate sample for each exercise that includes the management pack completed at the end of that exercise and each preceding exercise.  This strategy allows you to work through each exercise in order and then compare your results.  For VSAE, this also includes the Visual Studio solution. 

Details

The workflows created in this procedure have the following characteristics:

 


Authoring Console Procedure

The workflows created in this procedure have the following characname="Create_Probe_Action_Module_to_Run_a_Script">Create data source module to run script on schedule

  1. In the Authoring Console, select Type Library and then Data Sources.
  2. Right-click in the Data Sources pane and select New and then Composite Data Source.
  3. In the Choose a unique identifier box, type MyMP.DataSourceModule.MyPerformanceScriptTimed. Click OK
  4. On the General tab, do the following:
    1. In the Name box, type Timed Performance 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 Microsoft.Windows.TimedScript.PropertyBagProbe.
    3. In the Module ID box, type Script. Click OK.
    4. Click the button to the right side of the IntervalSeconds box and select Promote. This will enter the text $Config/IntervalSeconds$ 
    5. Click the button to the right side of the SyncTime box and select Promote. This will enter the text $Config/SyncTime$.
    6. In the ScriptName box, type MyCookdownScript.vbs.
    7. In the Arguments box, type $Config/ComputerName$ $Config/Version$.
    8. In the TimeoutSeconds box, type 300.
    9. Click the Edit… button. This starts the custom editor.
    10. 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)
      sVersion = WScript.Arguments(1)
      Set oAPI = CreateObject("MOM.ScriptAPI")
      oAPI.LogScriptEvent "MyCookdownScript.vbs",10,4, "Running script on " & sComputerName & ". Version is " & sVersion
       
      For i = 1 to 3
         Set oBag = oAPI.CreatePropertyBag()
         Call oBag.AddValue("ComputerName",sComputerName)
         Call oBag.AddValue("ComponentName","Component" & i)
         Call oBag.AddValue("Value",30)
         oAPI.AddItem(oBag)
      Next
       
      oAPI.ReturnItems
      ]]>
       
                 
    11. Close the editor to save the script back to the module.
    12. If you receive an error that says 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.
    13. Click OK to save the module configuration.
    14. Click Add to add a new module.
    15. In the Choose Module Type box, select System.Performance.DataGenericMapper.
    16. In the Module ID box, type MapToPerf. Click OK.
    17. In the ObjectName box, type MyApp.
    18. In the CounterName box, type TestCounter.
    19. In the InstanceName box, type $Data/Property[@Name='ComponentName']$
    20. In the Value box, type $Data/Property[@Name='Value']$.
    21. Click OK.
    22. In the NextModule column for the Script module, select MapToPerf.
    23. In the NextModule column for the MapToPerf 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.
    3. In the Simple Configuration Schema section, click Add to add a parameter.
    4. In the Please enter the requested value box, type ComputerName. Click OK.
    5. In the Simple Configuration Schema section, click Add to add a parameter.
    6. In the Please enter the requested value box, type Version. Click OK.
  7. 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. Change Configuration Element to Integer
    4. Click Add, then SyncTime
    5. In the Choose a unique identifier box, type SyncTime. Click OK.
  8. On the Data Types tab, do the following:
    1. In the Output Data section, in the Data Type: box select System.Performance.Data.
  9. Click OK to save the module.
  10. Select File, and then click Save.

 

Create Data Source Module to Filter on Instance

  1. Select Type Library and then Data Sources.
  2. Right-click/em>. Click OK
  3. Change Configuration Element to Integer
  4. Click Add, then SyncTime
  5. In the Choose a unique identifier box, type SyncTime. Click OK.
  • On the Data Types tab, do the following:
    1. In the Output Data section, in the Data Type: box select System.Performance.Data.
    the Data Sources pane, select New, and then Composite Data Source.
  • In the Choose a unique identifier box, type MyMP.DataSourceModule.MyPerformanceScriptFiltered. Click OK
  • On the General tab, do the following:
    1. In the Name box, type Filtered Performance Script Data Source.
  • On the Member Modules tab, do the following:
    1. Click Add to add a module.
    2. In the Choose Module Type box, select MyMP.DataSourceModule.MyPerformanceScriptTimed.
    3. In the Module ID box, type Script. 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 Computer box and select Promote. This enters the text $Config/ComputerName$.
    6. Click the button to the right side of the Version box and select Promote. This enters the text $Config/Version$.
    7. Click Edit. This starts the custom editor. 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.
    8. After the line:

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

      add the following line:

      <SyncTime>$Config/SyncTime$</SyncTime>                
    9. Close the editor to add the XML back the Authoring console.  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.
    10. Click OK to save the module configuration.
    11. Click Add to add a new module.
    12. In the Choose Module Type box, select System.ExpressionFilter.
    13. In the Module ID box, type FilterComponent. Click OK.
    14. Click Configure to open the Expression dialog box.
    15. Click Insert.
    16. In the Parameter Name box type InstanceName.
    17. In the Operator box select Equals.
    18. In the Value box type $Config/ComponentName$.
    19. Click OK to save the expression.
    20. Click OK to save the module configuration.
    21. In the NextModule column for the Script module, select FilterComponent.
    22. In the NextModule column for the FilterComponent module, select Module Output.
  • On the Configuration Schema tab, do the following:
    1. Change the Type for the IntervalSeconds parameter to Integer.
    2. In the Simple Configuration Schema section, 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 the SyncTime parameter. The SyncTime parameter is optional for this module.
    5. Click the Up arrow to the right of the Simple Configuration Schema section until the SyncTime parameter is directly under the IntervalSeconds parameter.
    6. In the Simple Configuration Schema section, click Add to add a parameter.
    7. In the Please enter the requested value box, type ComponentName. Click OK.
  • 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.
  • On the Data Types tab, do the following:
    1. Ensure the value in the Data Types box is System.Performance.Data.
  • Click OK to save the module.
  • Select File, and then click Save.
  • Create Rule to Collect Performance Data

    1. Select Health Model, then Rules.
    2. Right-click the Rules pane and select Configuration Element to Integer.
    3. Click Add and then SyncTime.
    4. In the Choose a u> New, then Custom Rule.