MOM 2005 Response Script Tracing

I've been writing a MOM response script that stopped working at some point, so I had to debug or trace it. Of course, at the time I was able to check it, the problem already got solved. So, I decided to turn on tracing and give some time for the problem to re-occur.

The script was developed to write trace messages at different points using the ScriptContext.Echo(string) method, but I never tried this feature. I did a search on MSDN and found that I have to enable debugging on the *MOM AGENT* (my script runs on a remote agent box, so I have to do it there) in order to get these messages logged somewhere. The following article shows the registry keys: msdn2.microsoft.com/en-us/library/ms824564.aspx. Briefly, they are:

  • HKEY_LOCAL_MACHINE\SOFTWARE\Mission Critical Software\OnePoint\EnableActiveDebugging= 1
  • HKEY_LOCAL_MACHINE\SOFTWARE\Mission Critical Software\OnePoint\DebugEnabledScripts = <Your Response Script name>

Did that, restarted the MOM service on the agent box and found that a new log file created under C:\WINDOWS\Temp\Microsoft Operations Manager with a name of "AgentResponses-<Mgmt group name> MOM.log", containing the last trace result of my response script.

So far so good, but I want to let my script-friend here doing his job and I want MOM to log every run, so I could analyze it next week when I come back. Unfortunately, MOM doesn't provide this nice feature to you, so I had to write my own scheduled task that does it:

1. Created a batch script, called MomLogGatherer, with the following content (the current trace file is assigned to an existing file):

type "C:\WINDOWS\Temp\Microsoft Operations Manager\AgentResponses-<Mgmt group name> MOM.log" >> C:\dszabo_MS\MomLog\momlog.txt

2. Created a scheduled task to call the batch script in every 5 minutes (the response script in MOM is scheduled to run in every 5 mins)

I just have to take care to archive the file sometimes before it gets too big.