This can be done with the following vb-Script:
Please copy the script into PRTGs subfolder for Custom Script Sensors "\PRTG Network Monitor\Custom Sensors\EXE" and then add a sensor in PRTG choosing this script. A few things have to be considered when you want to use this script:
Demo VBScrpt - Monitors WWS of Process X
Dim lByte
Dim lSumme
lByte = 0
lSumme = 0
strComputer = "."
set Param = wScript.Arguments
if Param.Count < 1 Then
WScript.echo "4: No parameters set"
WScript.Quit(4)
ElseIf Param.Count > 2 Then
WScript.echo "4: Too many parameters"
WScript.Quit(4)
ElseIf Param.Count < 2 Then
On Error Resume Next
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
if Err.Number > 0 then
WScript.echo "4: Access denied"
WScript.Quit(4)
Err.Clear
end if
else
On Error Resume Next
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& Param(1) & "\root\cimv2")
if Err.Number > 0 then
WScript.echo "4: Access denied"
WScript.Quit(4)
Err.Clear
end if
end if
Set colItems = objWMIService.ExecQuery( _
"Select * from Win32_Process WHERE name ='"&Param(0)&"'")
For Each objProcess in colItems
lByte = CLng (lSumme)
lSumme = CLng (objProcess.WorkingSetSize) + CLng (lByte)
Next
WScript.echo lSumme & ":OK"
- The script expects two parameters (they can be set in the Settings-tab of the sensor in PRTG, the field is "Parameters"):
- First the name of Process which should be monitored.
- Secondly the name of the target machine. This parameter can be left, then the check runs on the local machine (the probe machine under which the sensor runs in PRTG)
- Example: "chrome.exe server2003.mydomain.local" (without the "")
- The script returns the size of the Working Set in bytes, cumulated if more than instance of the particular process is running.
- It is most likely necessary to run the according PRTG Probe under a (domain) administrators account, as the LOCAL SYSTEM-Account does probably not have sufficient access rights/permission to request the information from other targets than the local machine.
Add comment