Tuesday, March 11, 2008

Ideas for WMI monitoring in ITM 6.1

As John Willis pointed out in his earlier articles, the ITM 6.1 monitoring in Windows is based on Perfmon API. Does it mean that we can not use WMI in Windows for our monitoring needs? Not quite so. Here is an example.

One could easily write a script in VBScript or Perl to query WMI information and pass this information to ITM using UA Script Data Provider. Here is an outline for the solution.

Step 1: Write a script to pull WMI information
Step 2: Write a MDL that maps the script output to ITM attributes
Step 3: Test & Import the Script and MDL
Step 4: Create situations and situation handlers. (such as TEC rules).

Let us take a hypothetical example here.

Querying Windows Product Activation Information

For example, if you want to query all your managed systems to see if they require Windows Product activation or compare the installed Windows Product ID with your licensed Product ID to make sure all systems have a correct copies of Windows installed.

A VBScript to gather WMI information
The following VB script queries the Windows Product Activation object in WMI and displays the status on the standard output.

Option Explicit
On Error Resume Next
dim strComputer
dim wmiNS
dim wmiQuery
dim objWMIService
dim colItems
Dim objItem

strComputer = "."
wmiNS = "\root\cimv2"
wmiQuery = "Select * from Win32_WindowsProductActivation"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & wmiNS)
Set colItems = objWMIService.ExecQuery(wmiQuery)

For Each objItem In colItems
WScript.StdOut.Write objItem.ActivationRequired & ";"
WScript.StdOut.Write objItem.IsNotificationOn & ";"
WScript.StdOut.Write objItem.ProductID & ";"
WScript.StdOut.Write objItem.RemainingEvaluationPeriod & ";"
WScript.StdOut.Write objItem.RemainingGracePeriod & ";"
WScript.StdOut.Write objItem.ServerName

A sample script output is shown here.


A Sample MDL
Now, you can write an MDL to capture this information and forward this to ITM. A Sample, untested MDL is given below.

//Name WinProductActivation K 1200 AddTimeStamp
//Source script cscript.exe //Nologo C:\apps\tivoli\ua\scripts\Activation.vbs Interval=60
//Attributes ';'
HostName (GetEnvValue = HOSTNAME)
Script (GetEnvValue = PROBE)
PreviousValue (GetEnvValue = PREV_VALUE)
ActivationRequired S 1
IsNotificationOn S 1
ProductID D 23
EvaluationPeriod C 9999999999
GracePeriod C 9999999999
ServerName D 25

Once the above MDL is imported and necessary situations are created, you can keep track of Windows Product activation status. We are not going to discuss these steps it is very well documented in ITM 6.1 manuals.

Please note that the basic purpose of this article is to illustrate how to collect WMI information using ITM 6.1. This example itself may not be practical. The obvious disadvantage of this solution is that you may want to run this script only once on each system and not everytime. To make this solution practical, you may have to modify this script to accept list of systems and print out their Windows Product Activation status.

No comments: