fix: address CodeRabbit review — guard OIDC group types and CPU division

This commit is contained in:
Thomas Camlong committed 2026-08-03 17:09:05 +02:00
1 parent ac8e0b1abe
commit ef9ead60ba
2 files changed
+16 -4

No files matched your search

@@ -41,6 +41,9 @@ export class UnraidIntegration extends Integration implements ISystemHealthMonit
// We use the thread count (not physical cores) because each logical CPU entry in cpus[]
// represents a thread. Dividing by cores would over-report utilization on SMT systems.
// Guard against zero or negative thread counts to avoid Infinity/NaN.
const cpuUtilizationNormalized = cpuCount > 0 ? cpuUtilization / cpuCount : 0;
const totalMemory = systemInfo.info.memory.layout.reduce((acc, layout) => layout.size + acc, 0);
const usedMemory = totalMemory * (systemInfo.metrics.memory.percentTotal / 100);
const uptime = dayjs(systemInfo.info.os.uptime);
@@ -48,7 +51,7 @@ export class UnraidIntegration extends Integration implements ISystemHealthMonit
return {
version: systemInfo.info.os.release,
cpuModelName: systemInfo.info.cpu.brand,
cpuUtilization: cpuUtilization / cpuCount,
cpuUtilization: cpuUtilizationNormalized,
memUsedInBytes: usedMemory,
memAvailableInBytes: totalMemory - usedMemory,
uptime: dayjs().diff(uptime, "seconds"),