Skip to content

Commit c9cdce1

Browse files
author
Lorenz Kästle
committed
Sum up TotalLoad over all CPUs and divide it by number of threads
On uncommon system configurations (number of sockets > 1) the TotalLoad perfdata of Invoke-IcingaCheckCpu was to high due to it being just summed up over all sockets. This patch changes this computation, the load weighted by the number of sockets is summed up and then divided by the total number of CPUs.
1 parent 262f0c4 commit c9cdce1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/provider/assets/cpu/Get-IcingaProviderDataValuesCpu.psm1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,16 @@ function Get-IcingaProviderDataValuesCpu()
4747

4848
foreach ($entry in $SocketList.Keys) {
4949
$SocketList[$entry].TotalLoad = $SocketList[$entry].TotalLoad / $SocketList[$entry].ThreadCount;
50-
$TotalCpuLoad += $SocketList[$entry].TotalLoad;
50+
$TotalCpuLoad += $SocketList[$entry].TotalLoad * $SocketList[$entry].ThreadCount;
5151
$TotalCpuThreads += $SocketList[$entry].ThreadCount;
5252

5353
$CpuData.Metadata.Sockets | Add-Member -MemberType NoteProperty -Name $entry -Value (New-Object PSCustomObject);
5454
$CpuData.Metadata.Sockets.$entry | Add-Member -MemberType NoteProperty -Name 'Threads' -Value $SocketList[$entry].ThreadCount;
5555
$CpuData.Metrics.$entry | Add-Member -MemberType NoteProperty -Name 'Total' -Value $SocketList[$entry].TotalLoad;
5656
}
5757

58+
$TotalCpuLoad /= $TotalCpuThreads;
59+
5860
$CpuData.Metadata | Add-Member -MemberType NoteProperty -Name 'TotalLoad' -Value $TotalCpuLoad;
5961
$CpuData.Metadata | Add-Member -MemberType NoteProperty -Name 'TotalThreads' -Value $TotalCpuThreads;
6062
$CpuData.Metadata | Add-Member -MemberType NoteProperty -Name 'CoreDigits' -Value ([string]$TotalCpuThreads).Length;

0 commit comments

Comments
 (0)