달력

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

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)

:
Posted by 커널64