Testing and developing MOM scripts outside MOM.
Here’s a simple and good working solution to test and develop your mom scripts without buying MP studio enterprise.
1) Install Visual studio 2003 or Visual studio 2005
2) Install the “responsetest.exe” from the “MOM resource tool kit 2005 sp1”
3) Create a “empty” solution as “test mom scripts”
(and you would add it to sourcesafe also 😉 )
4) Create a “empty” project as “mom vbs”
5) Add a new “vbscript” item , name it “test1.vbs”
Fill it with example code:
set oEvent = ScriptContext.CreateEvent
oEvent.EventNumber = 1
oEvent.EventSource = “SampleScript.txt”
oEvent.Message = “This is a event. Prameter is :” & ScriptContext.Parameters.Get(“Test Param”)
ScriptContext.Submit oEvent
6) Create a file “test.cmd” in the project directory
Fill it with the batch code: (make sure your path to the responsetest.exe is correct)
:: Enter the name below of the script your editing (NO .vbs !)
set MOM_SCRIPT=test1
set MOM_RESPONSE=%MOM_SCRIPT%_RESPONSE.xml
set MOM_CONFIG=%MOM_SCRIPT%_Config.xml
“C:Program FilesMicrosoft Operations Manager Resource KitToolsResponse Test UtilityResponseTest.exe” /q /d /out:%MOM_RESPONSE% /script:%MOM_SCRIPT%.vbs /config:%MOM_CONFIG%
7) Add the existing item file “test.cmd” to the project.
8) Add an new XML Item named “test1_CONFIG.XML”
Fill it with the parameter info that will be used for calling the mom script.
Test
9) Now edit the “mom vbs” project properties.
· Click the “configuration manager”
· Create a new configuration. Name it “MOM response via test.cmd”. then close.
· Under “common properties” change the “output type” to “class library” . then Apply
· Under “Debugging” change the “start application” to “c:windowssystem32cmd.exe”. then apply
· Under “Debugging” change the “command line Arguments” to “/t test.cmd”. then apply an OK.
If you done this all you can now press F5 and it will run the test1.vbs code. The output is stored in the directory where you installed the responsetest.exe and is named “test1_RESPONSE.xml”. Drag this file into your project and set the view mode to DATA. Now you will see all the events (1) that the MOM script “test1.vbs” will create if it runs in MOM.
!!!! Be aware that all vb code is executed in real. Only the mom events / performance events are simulated !!!!!!!
see also: http://www.microsoft.com/technet/scriptcenter/topics/mom/mom3.mspx
Here some action screen shots:
Editing the MP:
Editing the parameters:
Viewing the results: