프로세스 사용 메모리 (WorkingSet) 임계치 VB Script (VBS) SystemCenter2009. 7. 14. 11:56
Monitor -> New -> Scripting -> Timed Script Two State Monitor
Parameters
[ProcessName.exe] [WorkingSetLimit(MB)]
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']$
----------------------------------------------------------------------------------------------
'Parameter [ProcessName.exe] [WorkingSetLimit(MB)]
Dim oAPI, oBag
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
Set oArgs = WScript.Arguments
strTaskName = oArgs(0)
strWorkingSet = oArgs(1)
Set oArgs = nothing
Set shellobj = WScript.CreateObject("WScript.Shell")
State = "Good"
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Process where name ='" & strTaskName & "'", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
if clng(objItem.WorkingSetSize/(1024*1024)) > clng(strWorkingSet) then
strMsg = objItem.Name & "(이)가 WorkingSet 임계치(" & strWorkingSet & "MB)를 초과합니다. " & objItem.Name & "의 현재 WorkingSet은 " & clng(objItem.WorkingSetSize/(1024*1024)) & "MB 입니다."
State = "Bad"
end if
Next
Set shellobj = nothing
Call oBag.AddValue("State",State)
Call oBag.AddValue("Message",strMsg)
Call oAPI.Return(oBag)