mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 15:19:58 -05:00
Improved performance for CPU plugin execution with digit detection
This commit is contained in:
parent
5c683d95b2
commit
41b10c69dd
1 changed files with 3 additions and 2 deletions
|
|
@ -14,15 +14,16 @@ function Invoke-IcingaCheckCPU()
|
||||||
|
|
||||||
$CpuCounter = New-IcingaPerformanceCounter -Counter ([string]::Format('\Processor({0})\% processor time', $Core));
|
$CpuCounter = New-IcingaPerformanceCounter -Counter ([string]::Format('\Processor({0})\% processor time', $Core));
|
||||||
$CpuPackage = New-IcingaCheckPackage -Name 'CPU Load' -OperatorAnd -Verbos $Verbose;
|
$CpuPackage = New-IcingaCheckPackage -Name 'CPU Load' -OperatorAnd -Verbos $Verbose;
|
||||||
|
$CpuCount = ([string](Get-IcingaCpuCount)).Length;
|
||||||
|
|
||||||
if ($CpuCounter.Counters.Count -ne 0) {
|
if ($CpuCounter.Counters.Count -ne 0) {
|
||||||
foreach ($counter in $CpuCounter.Counters) {
|
foreach ($counter in $CpuCounter.Counters) {
|
||||||
$IcingaCheck = New-IcingaCheck -Name ([string]::Format('Core {0}', (Format-IcingaDigitCount $counter.Instance -Digits ([string](Get-IcingaCpuCount)).Length -Symbol ' '))) -Value $counter.Value().Value -Unit '%';
|
$IcingaCheck = New-IcingaCheck -Name ([string]::Format('Core {0}', (Format-IcingaDigitCount $counter.Instance -Digits $CpuCount -Symbol ' '))) -Value $counter.Value().Value -Unit '%';
|
||||||
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
||||||
$CpuPackage.AddCheck($IcingaCheck);
|
$CpuPackage.AddCheck($IcingaCheck);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$IcingaCheck = New-IcingaCheck -Name ([string]::Format('Core {0}', (Format-IcingaDigitCount $Core -Digits ([string](Get-IcingaCpuCount)).Length -Symbol ' '))) -Value $CpuCounter.Value().Value -Unit '%';
|
$IcingaCheck = New-IcingaCheck -Name ([string]::Format('Core {0}', (Format-IcingaDigitCount $Core -Digits $CpuCount -Symbol ' '))) -Value $CpuCounter.Value().Value -Unit '%';
|
||||||
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
||||||
$CpuPackage.AddCheck($IcingaCheck);
|
$CpuPackage.AddCheck($IcingaCheck);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue