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 topHealth 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:
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 topTo 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("Scripting.FileSystemObject")
set f = fso.CreateTextFile("C:\argTest.log", True)
f.Writeline "Test: " & 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.<Property Name>
- 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