You can develop a custom runtime script to create monitoring data for use in a Management Pack. To create monitoring data, a script creates a MOMPropertyBag object, which stores a set of name-value pairs. After adding as many name-value pairs to the object as are needed, a script submits the data to a Management Server for processing.

To develop a monitoring script

  1. Create a new script in any script authoring environment. For more information about creating scripts, see Getting Started Developing Runtime Scripts.

  2. Create an instance of the Operations Manager scripting object (MOMScriptAPI).

  3. Create a new property bag instance by calling the scripting object's MOMScriptAPI.CreatePropertyBag method.

  4. Add any number of name-value pairs to the property bag by calling the MOMPropertyBag.AddValue method for each name-value pair.

  5. Submit the property bag to Operations Manager for processing by calling the scripting object's MOMScriptAPI.Return method.

  6. Add the script to a Management Pack. The Management Pack defines the script, configures the script's arguments, and defines how frequently the script runs. For more information, see How to Use Monitoring Data in a Management Pack.


This section provides a simple example script written in VBScript. The example script reads the size of all files in a specified directory and creates a name-value pair for each file. The pair consists of the file's name and size (expressed in kilobytes). The script then submits the monitoring data to a Management Server for processing.

The script requires the following argument:

  • sPath—The directory containing the files whose size should be monitored.

The argument's value is passed to the script by the monitor, rule, or task that runs the script.

Visual Basic Script  Copy Code
Option Explicit
Dim oAPI
Set oAPI = CreateObject("MOM.ScriptAPI")

' Check for the required script arguments.
Dim oArgs
Set oArgs = WScript.Arguments
if oArgs.Count < 1 Then
	' If the script is called without the required arguments,
	' create an information event and then quit. 
	Call oAPI.LogScriptEvent("CollectAppYComponentFileSize.vbs",101,0, _
		"CollectAppYComponentFileSize script was called without any " _
		& "arguments and was not executed. ")
	Wscript.Quit -1
End If

Dim sPath
sPath = oArgs(0) ' The path of the directory containing the files.

Dim oFso, oFile, oFolder, oBag, oSize
Set oFso = CreateObject("Scripting.FileSystemObject")

if (oFso.FolderExists(sPath)) Then
	Set oBag = oAPI.CreatePropertyBag()
	Set oFolder = oFso.GetFolder(sPath)
	For Each oFile in oFolder.Files
		oSize = oFile.Size/1024
		Call oBag.AddValue(oFile.Name, oSize)
	Call oAPI.Return(oBag)
End If

See Also

Send comments about this topic to Microsoft.
[an error occurred while processing this directive]