WMI Process Sensors seems not to accept wildcards. How can I monitor the CPU Usage of multiple processes using wildcards?
How can I monitor CPU Usage of multiple processes using Wildcard?
Votes:
0
5 Replies
Votes:
0
Hello,
that might only be possible using a self-written script which runs as a Custom Sensor in PRTG.
Best Regards.
Votes:
0
Got now this powershell script and modified it to PRTG needs:
function Get-CPU { param( [string] $computer = $env:COMPUTERNAME, [string] $Proc, [int] $threshold = 0 ) $ErrorActionPreference = "SilentlyContinue" # Test connection to computer if( !(Test-Connection -Destination $computer -Count 1) ){ Write-Host "4: Could not connect to :: $computer" return } # Get all the processes $processes = Get-WmiObject -ComputerName $computer ` -Class Win32_PerfFormattedData_PerfProc_Process ` -Property Name, PercentProcessorTime $return= @() # Build up a return list foreach( $process in $processes ){ if( $process.PercentProcessorTime -ge $threshold ` -and $process.Name -ne "Idle" ` -and $process.Name -match $Proc ` -and $process.Name -ne "_Total"){ $item = "" | Select Name, CPU $item.Name = $process.Name $item.CPU = $process.PercentProcessorTime $return += $item $item = $null } } # Sort the return data $cpuusage = $return | measure-object -Property CPU -Average | fl Average | out-string -s | ? {$_} $cpuusage = $cpuusage.replace("Average : ","") $cpuusage = $cpuusage.replace("`n","") $output = $cpuusage.Substring(0, 4) + ":OK" return $output } Get-CPU
PRTG is reporting for example 14,00% instead 1,4%. When running the script from powershell it reports correctly, where I'm wrong with my script?
Created on Sep 3, 2010 9:59:18 AM
Last change on Sep 3, 2010 2:17:35 PM by
Torsten Lindner [Paessler Support]
Votes:
0
Hello,
do you have the Sensor in PRTG set to be an Integer or Float-Type?
Best Regards.
Votes:
0
Was on Integer. I've changed the script to report only full procents. Means if the the processes take 1,23%, the script returns the value 1%
Thank you
Votes:
0
Hello,
just as a tip, on the "Channels"-Tab you can change the amount of displayed decimal places, if you were to re-create the sensor as a float-type.
Best Regards.
Add comment