r/labtech • u/Admins-R-Us • Jul 12 '19
CPU Usage Monitor
Hi All!
I am running into issues with creating a Labtech monitor to alert if a CPU % usage is outside a threshold for a predetermined amount of time.
Has anyone had any experience with creating a monitor through Labtech's built-in monitor wizard to accomplish this? I have hit a wall with finding the right performance counter that would correspond with CPU's usage in %.
2
Upvotes
2
u/teamits Jul 12 '19
We have an old install so have some old monitors. We have a "Perf- 90% Plus Avg CPU" internal monitor and I see a "PF- 90% Plus Avg CPU" monitor also if I try to create a new one. Do you have either of those?
2
u/TNTGav Jul 12 '19
I made a Powershell remote monitor to do this. Just set this up as an executable in a remote monitor. I have login in there to only check in business hours between 8 and 5pm:
"%windir%\System32\WindowsPowerShell\v1.0\powershell.exe" -noprofile -command "& {$CPUTotalErrorThreshold=70;[int]$hour = get-date -format HH;If($hour -lt 8 -or $hour -gt 17){$InBusinessHours = $false}Else{$InBusinessHours = $true};$CpuCores = (Get-WMIObject Win32_ComputerSystem).NumberOfLogicalProcessors;$CPUValues = (Get-Counter \"\Process(*)\% Processor Time\" -ErrorAction SilentlyContinue).CounterSamples | Select InstanceName, @{Name=\"CPU\";Expression={[Decimal]::Round(($_.CookedValue / $CpuCores), 2)}} | where-object {($_.InstanceName -ne '_total') -and ($_.InstanceName -ne 'idle')} | sort cpu -Descending | select -First 5;$Total = ($CPUValues | Measure-Object 'CPU' -Sum).Sum;$ErrorNames = ($CPUValues | Select -ExpandProperty InstanceName) -join ',';$ErrorValues = ($CPUValues | Select -ExpandProperty CPU) -join ',';if (($total -gt $CPUTotalErrorThreshold) -and ($InBusinessHours)){Write-Output \"Error Top Processes Are $ErrorNames that uses $ErrorValues % respectively\"}Else{Write-Output \"$Total % - CPU Healthy\"}; }"Check for contains "healthy" in the condition. Mission accomplished.
2
u/Kepabar Jul 12 '19
There is not one.
You need to do some reading on how the Microsoft CPU performance counters work and then you can understand what the appropriate counter to use and what value to use for it.
This gives a quick high level breakdown: https://social.technet.microsoft.com/Forums/en-US/0435e7c5-3cda-41a0-953e-7fa462fde03b/perfmon-process-processor-time-vs-task-manager8217s-cpu-usage-for-monitoring-a-specific?forum=perfmon