2012. 7. 13. 23:11
SCOM vbs 스크립트 - 프로세스 실행 상태 모니터 SystemCenter2012. 7. 13. 23:11
스크립트로 프로세스의 실행 상태 모니터링
SCOM System Center Operations Manager Script vbs
' 오류 상태 정의: Property[@Name='State'] 같음 BAD
SCOM System Center Operations Manager Script vbs
' 오류 상태 정의: Property[@Name='State'] 같음 BAD
' 정상 상태 정의: Property[@Name='State'] 같음 GOOD
' 중지된 프로세스 목록: $Data/Context/Property[@Name='StoppedProc']$
Dim oAPI, oBag
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
Set oArgs = WScript.Arguments
If oArgs.Count = 0 Then
Call oBag.AddValue("State", "GOOD")
Call oAPI.Return(oBag)
WScript.Quit
End If
StoppedProc = ""
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
For i = 0 to oArgs.Count - 1
Set colProcesses = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = '"& oArgs(i) & "'")
If colProcesses.Count = 0 Then
StoppedProc = StoppedProc & oArgs(i) & ", "
Call oBag.AddValue(oArgs(i), "Not running")
Else Call oBag.AddValue(oArgs(i), "Running("&colProcesses.Count&"ea)")
End If
Set colProcesses = NOTHING
Next
If StoppedProc <> "" Then
Call oBag.AddValue("State", "BAD")
Call oBag.AddValue("Stopped Process(es)",Left(StoppedProc,Len(StoppedProc)-2))
Else
Call oBag.AddValue("State", "GOOD")
End If
Call oAPI.Return(oBag)