Skip to content

Commit

Permalink
Added CPU performance
Browse files Browse the repository at this point in the history
  • Loading branch information
gavsto committed Nov 8, 2018
1 parent 73ae8fd commit 98a0bf5
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"%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\"}; }"








0 comments on commit 98a0bf5

Please sign in to comment.