Graphing and Monitoring Process Availability
This tip demonstrates a Universal Agent solution to monitor the availability of a selection of Windows processes over time. This solution is necessary when using ITM 6.1 to monitor the lifetime of critical processes: how long have they been up, when they went down, have the restarted etc.
The Universal Agent solution consists of three files:
A user-customisable list of which processes to monitor. The format is simply the Image Name of the process as it appears in Task Manager, e.g. “notepad.exe”, “DataServer.exe” etc. Each process must appear on a separate line, e.g.
This file is read on each cycle of the Universal Agent, and therefore can be edited by the user to add or remove processes as required.
A standard Universal Agent metafile, defining the data to return to the Tivoli Enterprise Portal (TEP). In this case it is simply the name of each process monitored and a status code of 1 if it is running and 0 if it is not. Using a number for status will make it easy to process the data in TEP graphs, tables and situations.
//NAME PROCESS_ONLINE K 60
//SOURCE SCRIPT cscript "e:IBMITMTMAITM6scriptsprocess_find.vbs //nologo"
PROCESS_NAME D 12 KEY
STATUS C 9
A VBScript that uses WMI to determine if a process if running and compares the results against the contents of the processList.txt file. VBScript was used as it can be deployed and executed natively on Windows machines:
'Force variables to be declared c.f. Perl's use strict
‘location of process list file, change as required to match your environment
Const PROCESS_LIST = “E:IBMITMTMAITM6scriptsprocess_list.txt”
Const FOR_READING = 1
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
‘read process list file into array and build WHERE clause for WMI call
whereClause = ReadFile(PROCESS_LIST, processList)
If whereClause <> “” Then
‘feed WHERE clause from process list into WMI to see if these processes are running
wmiList = WMIProcessLookup(whereClause)
Found = False
‘Compare results from WMI with list in file
Dim i, j
For i = 0 to Ubound(processList)
For j = 0 to Ubound(wmiList)
If processList(i) = wmiList(j) Then
‘WMI returned process with same name running
Found = True
‘write result to STDOUT stream to be picked up by UA as PROCESS_NAME;X
‘where X is 1 if running and 0 if not, note use of ; as delimiter between the two fields
If Found = True Then
Wscript.Echo processList(i) & “;1”
Wscript.Echo processList(i) & “;0”
Found = False
‘connect to WMI
Set objWMIService = GetObject(“winmgmts:” & “.”& “
‘request list of running processes that match our WHERE clause derived from process list file
Set colItems = objWMIService.ExecQuery(“SELECT * FROM Win32_Process ” & whereClause, “WQL”, _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
‘build array with results
i = 0
For Each o In colItems
Redim Preserve resultArray(i)
resultArray(i) = o.Name
i = i + 1
‘if no results return empty array
If i = 0 Then
‘in VBScript, to return a value, we assign the Function to it
WMIProcessLookup = resultArray
Function ReadFile(file, processArray)
‘open process list file
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objTextFile = objFSO.OpenTextFile (PROCESS_LIST, FOR_READING)
i = 0
‘read file and build WMI WHERE clause from list of process names, e.g. WHERE Description =’notepad.exe’ OR Description = ‘someImportantProcess.exe’
Do Until objTextFile.AtEndOfStream
line = objTextFile.Readline
‘skip blank lines
If line <> “” Then
Redim Preserve processArray(i)
processArray(i) = line
If (0 = i) Then ‘First line
whereClause = “WHERE Description = ‘” & processArray(i) & “‘”
whereClause = whereClause & ” OR Description = ‘” & processArray(i) & “‘”
i = i + 1
‘return the where clause
ReadFile = whereClause
Copy the files to the following locations on each system where the solution is required and you have pre-installed a Universal Agent. Note that the process_list.txt file need to be created.
Edit the following line in process_find.mdl to point to the location of process_find.mdl on your system:
//SOURCE SCRIPT cscript "E:IBMITMTMAITM6scriptsprocess_find.vbs //nologo"
Edit the following line in process_find.vbs to point to the location of process_list.txt on your system:
Const PROCESS_LIST = "E:IBMITMTMAITM6scriptsprocess_list.txt"
Open a command window, and change to your
<INSTALL_ROOT>IBMITMTMAITM6 directory, and type:
kumpcon validate process_list.mdl
Enter Import when prompted with:
KUMPS065I Do you wish to Import or Refresh this metafile?
Finally recycle your Universal Agent and log into the TEP, you should see a node called ONLINE_PROCESS underneath the Universal Agent for the modified system.
In order to track process status over time, we need to set our agent solution to record its data historically using the following process:
- In the TEP, select Edit -> History Configuration
- Choose ONLINE_PROCESS in the ‘Select a product’ combo-box
- Select ONLINE_PROCESS in the ‘Select Attribute Groups’ table and configure accordingly; ensuring that you press ‘Start Collection’ when finished and verify that the ‘Collection’ row value is set to ‘Started’.
If you wish to change the processes being monitored, simply update the process_list.txt file on the agent – ensuring one entry per line and the entry is as appears in the ‘Image Name’ field of task manager. On the next agent cycle, the changes will be displayed in the TEP.
Errors from the VBScript are written to the universal agent error logs automatically by the agent.
This solution monitors processes by Image Name, if a process is running via a generic host, such as Java, Perl or the command line; it cannot distinguish between these instances. For example, two Java programs would run under ‘java.exe’; this solution as it stands would not be able to tell which one of the two is running at any given time.
This solution is Windows only; however, it is possible to develop a similar solution for a Linux/Unix environment using Perl or Shell Script instead on VBScript and parsing the output of process listing commands such as ‘ps’ instead of using WMI. Moreover, if we mandated that the Windows boxes were to use Perl, we could develop a script to handle the different platforms process listing, and parse the results generically; thus providing an all in one solution.
The WMI process object has a property called CommandLine, which can be used to obtain the command line of each running process. This information can be used to distinguish between processes running with the same name, e.g. java.exe. However, it is only supported on Windows XP, 2003 and upwards. We could modify our script to take this into account, and therefore handle generic hosting processes correctly.
Here is an example workspace that can be created from our Universal Agent’s historical data, and hence track the availablity of our chosen processes: