Update to Scheduled Task Management Pack

August 12, 2014 – link to latest update: https://rburri.wordpress.com/2014/08/12/scheduled-task…pack-1-2-0-500/

Last updated February 16, 2009

This post is no longer up to date. Please follow this link to the Task Scheduler Management Pack for Windows Server 2003 and 2008 post, where the most recent release of the management pack is available for download.

schedule

 

The Scheduled Task Management pack has seen an update (Version 1.0.1.40). It can be downloaded it from here:
Original Post

Changes:

  • Added Scheduled Task current status monitor (catches ‘Could not start’)
  • No warning events 21405 during discovery any longer
  • at least OpsMgr 2007 SP1 is required
Advertisements

Running Timed Script Discovery without getting warning event 21405

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.