New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


How can I see which process takes most of my CPU cycles?

Votes:

1

Your Vote:

Up

Down

My system often has performance issues.

Is there a way to determine the Windows process that causes the highest CPU load?

cpu-load custom-script-exe custom-sensor exe-script-sensor load performance powershell prtg script taskmanager

Created on Oct 21, 2014 9:23:30 AM by  Arne Seifert [Paessler Support]

Last change on Mar 19, 2015 3:40:31 PM by  Martina Wittmann [Paessler Support]



3 Replies

Accepted Answer

Votes:

1

Your Vote:

Up

Down

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.

  1. Copy the script below into an editor and save it as .ps1 file.
  2. Put the file into the \Custom Sensors\EXE subfolder of your PRTG installation directory.
  3. 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.

Created on Oct 28, 2014 12:02:51 PM by  Arne Seifert [Paessler Support]

Last change on Oct 28, 2014 12:57:59 PM by  Gerald Schoch [Paessler Support]



Votes:

1

Your Vote:

Up

Down

Hello,

I have successfully managed to get Top CPU load for processes on remote computers, using the code above with some modifications here:

param([string] $comp, 
      [int] $minload)



$processes=Get-WmiObject -computer $comp -Class 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=(gwmi Win32_Process -ComputerName $comp | where {$_.ProcessId -eq $Process.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

Created on Jun 14, 2018 12:01:32 PM by  zoolaNder (10)



Votes:

0

Your Vote:

Up

Down

Hello zoolaNder,

Trying to run the script above, however, PRTG constantly shows “No Process at or above 0%” The script also fails at console. I am not proficient in PS. Can you tell me if there are any variables that I need to change, for example, the conputer name?

Created on Aug 30, 2018 11:23:13 AM by  rvmsol (0)



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.