Skip to content

Commit 4b4e692

Browse files
fix(unraid): report correct CPU utilization on hyper-threaded systems
The Unraid integration summed the per-thread CPU percentages and divided the total by the number of physical cores. On hyper-threaded systems there are more logical CPUs (threads) than physical cores, so the result was inflated — roughly doubled — and could even exceed 100% (e.g. a real 43% load reported as ~93%). Use the overall CPU utilization the Unraid API already reports (`metrics.cpu.percentTotal`, 0-100), which is the value Unraid itself displays, instead of recomputing it from the per-thread percentages. Closes #6082
1 parent 260b167 commit 4b4e692

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

packages/integrations/src/unraid/unraid-integration.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ export class UnraidIntegration extends Integration implements ISystemHealthMonit
3737
public async getSystemInfoAsync(): Promise<SystemHealthMonitoring> {
3838
const systemInfo = await this.getSystemInformationAsync();
3939

40-
const cpuUtilization = systemInfo.metrics.cpu.cpus.reduce((acc, val) => acc + val.percentTotal, 0);
41-
const cpuCount = systemInfo.info.cpu.cores;
42-
4340
// We use "info" object instead of the stats since this is the exact amount the kernel sees, which is what Unraid displays.
4441
const totalMemory = systemInfo.info.memory.layout.reduce((acc, layout) => layout.size + acc, 0);
4542
const usedMemory = totalMemory * (systemInfo.metrics.memory.percentTotal / 100);
@@ -48,7 +45,12 @@ export class UnraidIntegration extends Integration implements ISystemHealthMonit
4845
return {
4946
version: systemInfo.info.os.release,
5047
cpuModelName: systemInfo.info.cpu.brand,
51-
cpuUtilization: cpuUtilization / cpuCount,
48+
// Use the overall CPU utilization the Unraid API already reports (0-100),
49+
// which is the value Unraid itself displays. Previously the per-thread
50+
// percentages were summed and divided by the number of physical cores,
51+
// which double-counted on hyper-threaded systems (e.g. 24 threads over
52+
// 12 cores) and could even exceed 100%.
53+
cpuUtilization: systemInfo.metrics.cpu.percentTotal,
5254
memUsedInBytes: usedMemory,
5355
memAvailableInBytes: totalMemory - usedMemory,
5456
uptime: dayjs().diff(uptime, "seconds"),

0 commit comments

Comments
 (0)