mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 15:04:52 +09:00
Guard against div0 in cpuUsage (#918)
This commit is contained in:
1 parent
f2ca465ec6
commit
f588f7f8d4
1 file changed
+3
-1
@@ -132,7 +132,9 @@ export async function gatherSystemInfo(
|
||||
const currentIdleCpuMs = cpus.map(({ times }) => times.idle);
|
||||
const deltaTotalCpuMs = minZip(previousTotalCpuMs, currentTotalCpuMs).map(([prev, curr]) => curr - prev);
|
||||
const deltaIdleCpuMs = minZip(previousIdleCpuMs, currentIdleCpuMs).map(([prev, curr]) => curr - prev);
|
||||
const cpuUsage = minZip(deltaTotalCpuMs, deltaIdleCpuMs).map(([total, idle]) => (total - idle) / total);
|
||||
const cpuUsage = minZip(deltaTotalCpuMs, deltaIdleCpuMs).map(
|
||||
([total, idle]) => (total <= 0 ? 0 : (total - idle) / total)
|
||||
);
|
||||
previousTotalCpuMs = currentTotalCpuMs;
|
||||
previousIdleCpuMs = currentIdleCpuMs;
|
||||
const stats = await fs.statfs(".");
|
||||
|
||||
Reference in new issue
Block a user