|
Any node item in the detail pane of the Monitor
node in the Mom Admin Console is potentially capable of launching a context
sensitive task. This means you can expand the Alerts for a given system
and extract any of several variables that can be fed as parameters into the
script. All you have to do is right click, chose the Custom Task and
click execute.
For example, an Alert arrives advising you that a Service is
stopped. You may have implemented a response to automatically start the
service up again. You maybe want to know if this has worked and maybe
check that other, related services are running properly.
This is how its done.
-
Create a suitable script for the task. In this case it's going
to list the currently running services on the target computer. You must
have Administrator authority on all systems concerned. The downloadable
script supplied with this article is called GetServices.vbs, the crux of which
looks like this:
|
Set objSvc = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Set objSet = objSvc.ExecQuery("Select * from win32_service")
For Each obj in objSet
'Display the results
Next
|
-
Place the script in a secure folder on the machine where your Mom
Admin Console is running. In this example it is C:\MomCustomTasks but you could
use any - just make sure it is correctly entered in the command below.
-
In the Mom Admin Console, with the focus on the Monitor
node, Right Click, select New and Custom Task.
-
The Custom Tasks dialog opens
-
In the Task Available For drop down list, select
Alert Items
-
Click Add
-
Give your task a name and description. e.g. Get Services
-
Enter the following Command: Cmd /k Cscript.exe
C:\MomCustomTasks\GetServices.vbs
-
At the end of the command enter a space and then click
the Right Arrow at right hand side of the drop down list
field. This pulls up a list of available state variables. Select
Computer. This appends $Computer$ to the end of your
command. The full command looks like this:
-
Cmd /k Cscript.exe
C:\MomCustomTasks\GetServices.vbs $Computer$
-
Click OK, OK to close the dialog. It may take a few minutes
for Mom to write this new task into the database.
-
In the Mom Admin Console you can now select any node which displays
Alert data. By way of a test select the Open Alerts node.
Select an alert in the details pane (on the right) and Right Mouse click.
-
Select Custom Tasks and then pick GetServices.
-
GetServices runs, extracting the computer name from the Alert.
You should see a command prompt window open with the results displayed.
You may need to resize the Window for future use.
Other Custom Tasks
Now it's obvious how to configure your own tasks. Many of
the scripts on this site accept command line arguments can can easily be used
under these circumstances. You can use any valid operating system command
provided you have Authority to execute it.
Please accept this script as is. Any feedback will be
gratefully received at Debug@Huntland.co.uk
|