사용자 정의 프로세스 수 성능 카운터 (다중 파라미터) - VB Script SystemCenter2009. 3. 18. 16:48
getProcessNUM.vbs
arguement => Process1.exe,Process2.exe,Process3.exe......
Object : Process
Counter : NumberOfProcess
Instance : $Data/Property[@Name='ProcessName']$
Value : $Data/Property[@Name='PerfValue']$
--------------------------------------------------------------------------------------------------
Option Explicit
Const EVENT_TYPE_ERROR = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_SUCCESS = 4
Dim intResponse, strProcess, bLogPerformanceEvent, bGenerateSuccessEvent, bLogPerformanceData
Dim oAPI, oArgs, cProcessResult, oMOMBag, sProcess, propertyBag, perfValue
Dim ProcessName
Set oArgs = WScript.Arguments
Set oAPI = CreateObject("MOM.ScriptAPI")
If oArgs.Count < 1 Then
Call oAPI.LogScriptEvent("getProcessNUM.vbs", 10101, EVENT_TYPE_ERROR, "getProcessNUM script was called with fewer than one arguement.")
WScript.Quit -1
End If
strProcess = Split(oArgs.Item(0), ",")
For Each sProcess In strProcess
getProcessNUM(sProcess)
Next
oAPI.ReturnItems
Sub getProcessNUM(ProcessName)
Set cProcessResult = GetObject("winmgmts://./root/cimv2").ExecQuery("SELECT * FROM Win32_Process WHERE name = '" & ProcessName & "'")
perfValue= 0.0
perfValue= cdbl(cProcessResult.count)
Set propertyBag = oAPI.CreatePropertyBag()
propertyBag.AddValue "ProcessName", ProcessName
propertyBag.AddValue "PerfValue", PerfValue
oAPI.AddItem(propertyBag)
Call oAPI.Return(propertyBag)
Set cProcessResult = Nothing
End Sub