달력

1

« 2025/1 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
스크립트로 프로세스의 실행 상태 모니터링
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)


 
:
Posted by 커널64