My MVP Profile

Tuesday, March 07, 2006

Writing and Debugging Scripts in MOM

You may or may not be aware the MOM 2005 Resource Kit contains a new utility for debugging MOM Scripts called ResponseTest. This tool allows you to test the syntax of your MOM scripts from any machine where the MOM agent is running. ResponseTest has 2 modes: Default Mode and Run Mode.

 

 

The default mode outputs script results, including any error message, to responsetestoutput.xml in the same directory as the responsetest utility......This mode is a simulation only doesn't actually perform any action within MOM.

SYNTAX:
ResponseTest /script:c:\scripts\HelloWorld.vbs

In Run Mode, objects will actually be created in MOM. This can come in handy if you want your script to create events to validate that alert rules fire as expected, script output is what you wanted, etc.

SYNTAX:
ResponseTest /script:c:\scripts\HelloWorld.vbs /runmode:mom

 

NOTE: Bear in mind this is still not foolproof as scripts are running in the context of the user account with which you're logged in rather than the action account.

 

 

You can also take debugging a step further by performing Active Debugging, which involves attaching a remote debugger to the MOMHost process through Visual Studio. If you’d like to learn more about MOM script authoring and debugging, check the 4 part series “Scripting MOM” at the MS website. Parts 3 and 4 were recently published after the release of the refresh of the MOM 2005 Resource Kit. Part 3 and 4 were recently released in conjunction with the release of the refresh to the MOM Reskit.

Here is an overview of each of the articles in the series:

 

Part 1 – The Basics

Introduces the concepts behind MOM scripts compared to those in Windows Script Host and the common and different objects used by each. You will learn how to get output data from a script into the MOM workflow.

 

Part 2 – Getting Data into a Script

Focuses on getting data into a MOM script. This includes working with parameters and retrieving information from the MOM object that launches the script.

 

Part 3 – Writing and Debugging

Insight into the logistics of writing and debugging a script in MOM. This article covers the use of different editors and utilities for performing these functions.

 

Part 4 – Best Practices

Discussion of best practices and answers to general questions, such as: When should you generate an alert as opposed to an event with a MOM script? How complex should a MOM script be before you break it into multiple parts? What about security?

 

 


The MOM 2005 Resource Kit can be downloaded here.

 

Labels: ,

Comments on "Writing and Debugging Scripts in MOM"

 

post a comment links to this post