Monday, October 8, 2012

[SCOM 2007] Authoring Management Pack - Create a VBS discovery with a debugging functionnality - PART III

The first time the discovery script given in Part II is executed on a targeted machine, it try to read the debugging key in the registry.
If the key is not found, it creates a it in HKLM\SOFTWARE\Microsoft\Microsoft Operations Manager\Debugging.

The default value for the key is FALSE - That means that all the functions that are used for the debugging mode (See PART I) will not work.
If you want to activate the debugging mode on a specific server, just change the key value to TRUE on this server.


When discovery has run, you also have a property discovered in your main class that reflect the debug mode value.

It's now easy to work with the function that creates events in the Operations Manager Event Log in your script :

call sub_LogMPScriptEvent (10211, "My Event", Err, DebugModeValue,strMPScriptName,MOMEVENTLOGINFORMATION)

Where
- DebugModeValue is set with the value of the registry key created/read by the discovery
- strMPScriptName is the name of the discovery script
- MOMEVENTLOGINFORMATION is set with value 0
- 10211 will be the event number created in Operations Manager Event log.


Why using this debug mode : 

Last time I've used this key was to understand why my discovery script was well working when I was launching the VBS with a cscript with parameter in a shell (no script issue, property bags were set) but when the Discovery was lauched by SCOM, nothing was discovered !
I've also create an event that give all the variable used to set the property bags, imported the new MP, change the key on the server to set the debug mode to TRUE and force the discovery.

Analysing the Operations Manager log show me that I' was using a variable that didn't reflect the computer name and was always set to the same value... meaning that SCOM was not abled to discovers the services for the computer name since the computer name had a false value.

I've change the script to use the good displayName for the computer and tested it. The discovery was always working with no errors but this time, services were discovered ! :)

If you have any question, don't hesitate to contact me.

This posting is provided "AS IS" with no warranties.

No comments:

Post a Comment