Post last updated on: January, 20 2008
When writing management packs, I do occasionally use timed script discovery providers (Microsoft.Windows.TimedScript.DiscoveryProvider). At times such a script may end without returning any discovery data. Consider the following example:
– A timed script discovery rule is looking for an element (e.g. Windows scheduled tasks)
– For each found, an object entity is created in OpsMgr’s DB
– If none exist on the computer, the script quits silently
It is expected that the script does exit without returning any discovery data when the object does not exist on a computer. However; OpsMgr’s default setting will lead to the following event being written into the Operations Manager event log of the target computer:
Event Type: Warning Event Source: Health Service Modules Event ID: 21405 Description: The process started at ....... failed to create
System.Discovery.Data, no errors detected in the output.
The process exited with 0
After having tried various approaches, it was this post on the Operations Manager Product Team Blog that got me onto the right path.
If writing a discovery (or property bag) provider from which you expect to not return data at times.
- Make sure you end the script gracefully: WScript.Quit(0)
- At the end of the DataSource tag, add an EventPolicy tag:
<!--Do not write Warning Event 21405 (no discovery data)
when the script doesn't return any data
(product not installed) -->
<!--Standard Error Out Matches (leave default) -->
<!--Exit Code matches (leave default) -->
By setting <StdOutMatches> to nothing, you override the default setting which would create an event if anything other than a valid OpsMgr DataItemis being returned. Note that this will only work on OpsMgr 2007 SP1 and beyond.
Disappearing objects that were once discovered
Depending on the logic of the discovery script there is some danger that already discovered objects vanish from OpsMgr if the script fails to successfully read data from the agent machine. This might be a temporary failure of a WMI object. Microsoft’s DNS management pack did suffer from that until recently. Boris Yanushpolsky has an enlightning post on how to avoid this from happening. He is making use of the (so far undoocumented) IsSnapshot property of the CreateDiscoveryData object.