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)

2 Responses to Monitor a process in Operations Manager 2007 using a script

  1. vijay April 15, 2009 at 4:44 am #

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

  2. sea horse April 12, 2012 at 8:35 am #

    The above script is wrong…. Please give us the correct one…

Leave a Reply