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.

Design

The Universal Agent solution consists of three files:

process_list.txt 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.

notepad.exeperl.exe

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.

process_find.mdl 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.

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:

If whereClause <> “” Then ‘feed WHERE clause from process list into WMI to see if these processes are running Dim wmiList wmiList = WMIProcessLookup(whereClause)

Dim Found 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 Exit For End If Next

‘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” Else Wscript.Echo processList(i) & “;0” End If

‘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

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.

Usage

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.

Caveats

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.

Improvements

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.

Example

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: