From 98a0bf5a318b2dcceb4d32d941f057dca683166b Mon Sep 17 00:00:00 2001 From: Gavin Stone Date: Thu, 8 Nov 2018 23:54:31 +0000 Subject: [PATCH] Added CPU performance --- ...Performance Report top 5 processes and percentage.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Remote Monitor - Powershell CPU Performance Degraded Test/Check CPU Performance Report top 5 processes and percentage.ps1 diff --git a/Remote Monitor - Powershell CPU Performance Degraded Test/Check CPU Performance Report top 5 processes and percentage.ps1 b/Remote Monitor - Powershell CPU Performance Degraded Test/Check CPU Performance Report top 5 processes and percentage.ps1 new file mode 100644 index 0000000..311867d --- /dev/null +++ b/Remote Monitor - Powershell CPU Performance Degraded Test/Check CPU Performance Report top 5 processes and percentage.ps1 @@ -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\"}; }" + + + + + + + +