This probably will be a pain to integrate. The following PowerShell script will output the processes and their ram usage in byte:
param($target)
$Processes = get-process -ComputerName $target | Group-Object -Property ProcessName
Write-Host '<?xml version="1.0" encoding="UTF-8"?><prtg>'
Write-Host (@"
<result>
<channel>{0}</channel>
<value>{1}</value>
<Unit>Count</Unit>
</result>
"@ -f "Running processes",$Processes.Count)
foreach($Process in $Processes)
{
$Obj = New-Object psobject
$Obj | Add-Member -MemberType NoteProperty -Name Name -Value $Process.Name
$Obj | Add-Member -MemberType NoteProperty -Name Mem -Value ($Process.Group|Measure-Object WorkingSet -Sum).Sum
Write-Host (@"
<result>
<channel>{0}</channel>
<value>{1}</value>
<Unit>BytesMemory</Unit>
</result>
"@ -f $Obj.Name,$Obj.Mem)
}
Write-Host ("<Text>{0} processes are currently running</Text></prtg>" -f $Processes.Count);
Our EXE/Script XML sensor is destined for this :) However, you'll have to make sure that the script sensor needs the setting "Use credentials of parent device" (within the sensor). The credentials entered in the device configuration need administrative privileges on the target host, otherwise it won't work. Enter %host as parameter and you should be all set.
Note that you'll also have a lot of "dead" channels containing no values, depending on the amount of processes (the value will be 0 but the channel won't disappear).
Add comment