CPU Leistung ermitteln

Veröffentlicht:  24. Juni 2015

CPU Leistung ermitteln und bei bei festgelegten Grenzwerten Administrator informieren.

$WARNLEVEL = 25
$CRITLEVEL = 80

$cpuusage = (Get-WmiObject win32_processor | Measure-Object -property LoadPercentage -Average | Select Average)

if ( ($cpuusage.average) -lt $WARNLEVEL ) {
	Write-Host "[OK] CPU usage is normal: "($cpuusage.average)"%"
	exit 0
}
elseif ( ($cpuusage.average) -gt $CRITLEVEL ) {
	Write-Host "[PROBLEM] CPU usage is high: "($cpuusage.average)"%"
	exit 2
}
else {
	Write-Host "[WARNING] CPU usage is getting high: "($cpuusage.average)"%"
	exit 1
}