Monitor a process in Operations Manager 2007 using a script

Create a “Timed Script 2 State Monitor”.

Set your target as “Windows Server 2003″. Set the Monitor to disabled.

Use this script below (Set the processname = to the process you want to monitor)

————————————————-

On Error Resume Next

Dim oAPI, oBag
Set oAPI = CreateObject(“MOM.ScriptAPI”)Set oBag = oAPI.CreateTypedPropertyBag(StateDataType)

strComputer = “.”processname = “AeXNSAgent.exe” ‘Process name here

Set objWMIService = GetObject(“winmgmts:” _ & “{impersonationLevel=impersonate}!\\” &
strComputer & “\root\cimv2″)

strQuery = “Select * from Win32_Process Where Name = ‘” & ProcessName & “‘”Set colProcesses = objWMIService.ExecQuery (strQuery)

If colProcesses.Count = 0 Then

Call oBag.AddValue(“State”,”BAD”)Else Call oBag.AddValue(“State”,”GOOD”)

End If

Call oAPI.Return(oBag)

One Comment

  1. vijay:

    To monitor any process using script should ‘healthservice’ be running in agent machines??

Leave a comment