What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

How can I monitor CPU Usage of multiple processes using Wildcard?

Votes:

0

WMI Process Sensors seems not to accept wildcards. How can I monitor the CPU Usage of multiple processes using wildcards?

cpu-load process prtg wmi

Created on Sep 1, 2010 10:34:54 AM



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.

Created on Sep 1, 2010 2:59:00 PM by  Torsten Lindner [Paessler Support]



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.

Created on Sep 3, 2010 2:18:20 PM by  Torsten Lindner [Paessler Support]



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

Created on Sep 6, 2010 8:16:10 AM



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.

Created on Sep 6, 2010 9:23:39 AM by  Torsten Lindner [Paessler Support]




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.