Microsoft Operations Manager |
Debug MOM scripts either from the local computer or a remote computer using Microsoft Visual Studio .NET. Once the debugger is connected to the OnePoint service, you can step through scripts, set breakpoints, view the call stack, examine variables and objects, and use other debugging features in the Visual Studio .NET development environment. You can debug scripts running on either the MOM Consolidator computer or an agent computer.
To support remote debugging, install the full set of Visual Studio .NET debugging components on the computer running the script.
To install the remote debugging components on an agent computer or a Consolidator
The default settings on the MOM Consolidator and agents do not support attaching a debugger to the running MOM scripts. You must enable debugging through the Windows registry.
For scripts that run on agent computers, enable debugging on each agent computer you are debugging. If a script runs on the Consolidator, enable debugging on the Consolidator computer. This also allows you to debug agent scripts running on the Consolidator.
To turn debugging on and specify which scripts you want to debug
To disable debugging, change EnableActiveDebuggingto 0.
NoteDisable debugging after you have finished troubleshooting the problem. Enabling debugging will decrease performance, and other users could attach debuggers to the OnePointService.exe process and lock threads for extended periods of time.
Attaching the Debugger to MOM
To attach the debugger to an agent or Consolidator
- Start the Visual Studio .NET integrated development environment.
- On the Toolsmenu, click Debug Processes.
- In the Processesdialog box, type the name of the computer running the scripts in the Namebox.
- In the Available Processeslist, select OnePointService.exe, and then click Attach. Debug scripts on only one agent at a time.
- In the Attach to Processwindow, select Scriptfrom the list of program types to debug, and then click OK. All other types should be cleared.
- In the Debugged Processeslist, select the OnePointService.exeprocess, click Break, and then click Closeto save settings.
- Wait for a script matching the DebugEnabledScriptsregistry value to run.
To end the debugging session and detach from the OnePoint service, press Shift+F5 .
Debugging the Script
The first script matching the name or wildcard pattern specified in the DebugEnabledScriptsregistry entry opens in Visual Studio .NET. You can use the commands on the Debugmenu. You can also view the data displayed in the various debugging windows, such as the Localswindow and the Call Stackwindow. For more information about debugging with Visual Studio .NET, see Using the Debuggerin the Visual Studio .NET documentation.
When debugging MOM scripts, use the following guidelines:
- If script execution is paused for long periods of time as you debug the code, expect MOM to raise alerts indicating that your script did not run to completion in a timely manner. These alerts can be ignored while debugging.
- If the other scripts do not match the DebugEnabledScriptsregistry key or you press the Stepor Gobutton in the debugger, attaching the debugger locks the thread responsible for running your script until the debugging is complete. A locked script thread will not prevent other scripts from running using other available threads, but it does decrease performance.
- If a second instance of a script is started before you finish debugging the first instance, the second instance is prevented from running if it must wait longer than five minutes for the first instance to complete. If any script is prevented from running because of a debugging session or other causes, a MOM alert is raised.
- If you must restart the OnePoint service, first detach the debugger from the OnePoint process. Reattach the debugger to the new OnePoint process after it has started. If you do not explicitly detach the debugger, the debugger might not be aware that the service process has stopped.
- If you step through a script that has opened in the debugger until it exits and the next script to open in the debugger is the same script, the debugger will break into the script. Press F5 (the Continuecommand) to complete its execution, unless you want to step through the script again.
For more information about testing MOM scripts, see the MOM SDK for documentation about the RunScript.exe utility.
See Also
Remote Debugging Setup, Using the Debugger
Did you find this information useful? Please send your suggestions and comments about the documentation to momsdk@microsoft.com.