Raphael Burri's blog

Mostly about Systemcenter Operations Manager 2012

Running Timed Script Discovery without getting warning event 21405

Posted by rburri on May, 13 2008

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
Workaround

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.

  1. Make sure you end the script gracefully: WScript.Quit(0)
  2. At the end of the DataSource tag, add an EventPolicy tag:
<EventPolicy>
<!--Do not write Warning Event 21405 (no discovery data)
when the script doesn't return any data
(product not installed) -->
<StdOutMatches></StdOutMatches>
<!--Standard Error Out Matches (leave default) -->
<StdErrMatches>\a+</StdErrMatches>
<!--Exit Code matches (leave default) -->
<ExitCodeMatches>[^0]+</ExitCodeMatches>
</EventPolicy>

 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.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: