Microsoft KB Archive/817245

= HOW TO: Pass Data Collector Data to a Script Action in Health Monitor =

Article ID: 817245

Article Last Modified on 1/12/2007

-

APPLIES TO


 * Microsoft Application Center 2000 Standard Edition

-



IN THIS TASK

 * Summary
 * Introduction
 * Create a Script



SUMMARY
This step-by-step article describes how to use a Health Monitor data collector to pass the collected data to a Health Monitor script action.

back to the top

Introduction
Health Monitor is based on Windows Management Instrumentation (WMI). Because WMI executes the Health Monitor script actions, the WMI event data that Health Monitor data collectors generate can be retrieved by using the TargetEvent.EmbeddedStatusEvent object. When WMI executes the script action through Health Monitor, the TargetEvent.EmbeddedStatusEvent object is already available to the script and can be called without binding to the object first.

For more information about running scripts that are based on WMI events, visit the following Microsoft Web site:

Running a Script Based on an Event

http://msdn2.microsoft.com/en-us/library/aa393250.aspx

When you use a Health Monitor data collector to pass the collected data to a Health Monitor script action, remember the following:
 * Health Monitor data collectors cannot pass the collected data to a script action by using arguments. The TargetEvent.EmbeddedStatusEvent object must be used in the script to retrieve the collected data.
 * Health Monitor data collectors can pass the collected data to command-line actions by using arguments. However, you cannot use Cscript.exe with a command-line action.

back to the top

Create a Script
To create a simple Health Monitor script action that retrieves the data that is collected from the calling data collector, follow these steps:   Create a Health Monitor script action that points to a script that contains the following code. Note that the code uses the TargetEvent.EmbeddedStatusEvent.EmbeddedCollectedInstance object. Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;) set f = fso.CreateTextFile(&quot;C:\argTest.log&quot;, True) f.Writeline &quot;Test: &quot; & TargetEvent.EmbeddedStatusEvent.EmbeddedCollectedInstance.Name f.close This code creates a file at C:\Argtest.log and writes the name of the data instance that is collected from the calling data collector. Any property of the instance data can be retrieved in the same manner. The syntax is as follows: TargetEvent.EmbeddedStatusEvent.EmbeddedCollectedInstance.  Create a new Health Monitor data collector.

Note You can also use an existing Health Monitor data collector. Any kind of data collector will work. This example uses an SMTPSVC service monitor. Bind the data collector to the script action. Stop the SMTP service. The data collector reaches a critical condition threshold and executes the script action. The script receives the data collector data through the TargetEvent.EmbeddedStatusEvent.EmbeddedCollectedInstance object. This case uses the property Name, but you can use any property that the data collector supports. If you want to see a list of the properties that your WMI instance supports, view your WMI Event Query monitor in Health Monitor.

back to the top

Keywords: kbhowtomaster KB817245

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.