프로세스 실행 상태 모니터 (실행 상태만) SystemCenter2009. 2. 13. 16:14
Monitor -> New -> Scripting -> Timed Script Two State Monitor
Parameters
[Process1.exe] [Process2.exe] ....
State Expression
For Unhealthy Expression Property[@Name='State'] Equals Good
For Healthy Expresion Property[@Name='State'] Equals Bad
Alert Description
$Data/Context/Property[@Name='Message']$
---------------------------------------------------------------------------------------------------------------
ProcessRunCheck.vbs
Dim oAPI, oBag, oArgs, strProcess(), ProcessState()
strMessage = ""
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
Set oArgs = WScript.Arguments
ParamCount = oArgs.Count
State = 0
If ParamCount < 1 Then
Call oAPI.LogScriptEvent("ProcessRunCheck.vbs", 5009, 0, "Script aborted. Not enough parameters provided.")
WScript.Quit -1
End If
ReDim Preserve strProcess(ParamCount), ProcessState(ParamCount)
i = 0
Do While i <> ParamCount
strProcess(i) = oArgs(i)
i = i + 1
Loop
i = 0
Do While i <> ParamCount
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set ProcessState(i) = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = '" & strProcess(i) & "'")
If ProcessState(i).Count => 1 Then
Call oBag.Addvalue(strProcess(i),"Running(" & ProcessState(i).Count & "ea)")
strMessage = strMessage & strProcess(i) & ": " & "Running(" & ProcessState(i).Count & "ea)" & " | "
End If
If ProcessState(i).Count < 1 Then
Call oBag.Addvalue(strProcess(i),"Not running")
strMessage = strMessage & strProcess(i) & ": " & "Not running" & " | "
State = 1
End If
Set objWMIService = nothing
i = i + 1
Loop
If State = 0 Then
Call oBag.AddValue("State","Good")
Else
Call oBag.AddValue("State","Bad")
End If
Call oBag.AddValue("Message",strMessage)
Call oAPI.Return(oBag)