달력

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
2008. 11. 29. 09:08

프로세스 모니터 (개수 - 최소/최대) SystemCenter2008. 11. 29. 09:08

Monitor -> New -> Scripting -> Timed Script Two State Monitor

Parameters
[Process1.exe] [Lower value] [Upper value] [Process2.exe] [Lower value] [Upper value] ....

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']$

---------------------------------------------------------------------------------

ProcessCheck.vbs

Dim oAPI, oBag, oArgs, strProcess(), Lower(), Upper(), colProcess()
strMessage = " "

Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
Set oArgs = WScript.Arguments

ParamCount = oArgs.Count
State = 0

If ParamCount < 3 Then
Call oAPI.LogScriptEvent("ProcessCheck.vbs", 5009, 0, "Script aborted. Not enough parameters provided.")
WScript.Quit -1
End If

If (ParamCount Mod 3) <> 0 Then
Call oAPI.LogScriptEvent("ProcessCheck.vbs", 5010, 0, "Script aborted. The number of provided parameters is invalid.")
WScript.Quit -1
End If

ReDim Preserve strProcess(ParamCount), Lower(ParamCount), Upper(ParamCount), colProcess(ParamCount)

i = 0
Do While i <> ParamCount
strProcess(i) = oArgs(i)
Lower(i) = cInt(oArgs(i + 1))
Upper(i) = cInt(oArgs(i + 2))

If Lower(i) > Upper(i) Then
Call oAPI.LogScriptEvent("ProcessCheck.vbs", 5011, 0, "'" & strProcess(i) & " " & Lower(i) & " " & Upper(i) & "'" & " Lower value is bigger than upper value.")
WScript.Quit -1
End If

i = i + 3
Loop

i = 0
Do While i <> ParamCount
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcess(i) = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = '" & strProcess(i) & "'")

If colProcess(i).Count => Lower(i) and colProcess(i).Count =< Upper(i) Then
Call oBag.Addvalue(strProcess(i) & " (" & Lower(i) & "~" & Upper(i) & ")" ,colProcess(i).Count & "ea (Normal)")
strMessage = strMessage & strProcess(i) & " (" & Lower(i) & "~" & Upper(i) & ") : " & colProcess(i).Count & "ea (Normal)" & " | "
End If

If colProcess(i).Count < Lower(i) Then
Call oBag.Addvalue(strProcess(i) & " (" & Lower(i) & "~" & Upper(i) & ")" ,colProcess(i).Count & "ea (Too few)")
strMessage = strMessage & strProcess(i) & " (" & Lower(i) & "~" & Upper(i) & ") : " & colProcess(i).Count & "ea (Too few)" & " | "
State = 1
End If

If colProcess(i).Count > Upper(i) Then
Call oBag.Addvalue(strProcess(i) & " (" & Lower(i) & "~" & Upper(i) & ")" ,colProcess(i).Count & "ea (Too many)")
strMessage = strMessage & strProcess(i) & " (" & Lower(i) & "~" & Upper(i) & ") : " & colProcess(i).Count & "ea (Too many)" & " | "
State = 1
End If

Set objWMIService = nothing
i = i + 3
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