This article applies to PRTG Network Monitor 14 or later
Showing the Process with the Highest CPU Load
You can use the following PowerShell (PS1) script with the EXE/Script sensor.
- Copy the script below into an editor and save it as .ps1 file.
- Put the file into the \Custom Sensors\EXE subfolder of your PRTG installation directory.
- Add an EXE/Script sensor to your PRTG installation and choose this script during sensor setup.
Note: This script will work only on the local machine (either PRTG local probe, or a PRTG remote probe).
param(
[int]$minload
)
$processes=Get-WMIObject Win32_PerfFormattedData_PerfProc_Process | select IDProcess,Name,PercentProcessorTime | where { $_.Name -ne "_Total" -and $_.Name -ne "Idle"} | sort PercentProcessorTime -Descending | select -first 1
$topname=$Processes[0].Name
$topCPU=$Processes[0].PercentProcessorTime
$topdesc=(Get-Process -Id $Processes[0].IDProcess).Description
$result=$topCPU -as [string]
if ($topdesc.length -gt 0) {
$topname=$topdesc
}
$result=$result+":"+$topname
if ($topCPU -lt $minload) {
$result="0:No process at or above $minload%"
}
write-host $result
This sensor will show the process with the highest CPU load in the sensor status message. This message will not be saved by PRTG. It is not possible to use the historic data to see which process previously had the highest CPU load.
The script shows the thread's description and if none exists, the thread's name.
Add comment