From ac39a1152974132bb0a66e65bc883b966775c07f Mon Sep 17 00:00:00 2001 From: Morgan Date: Mon, 2 Mar 2026 02:34:36 +0900 Subject: [PATCH] use only total CPU usage --- .../cpuUsageUtil.js | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/freon@UshakovVasilii_Github.yahoo.com/cpuUsageUtil.js b/freon@UshakovVasilii_Github.yahoo.com/cpuUsageUtil.js index 69ef0ec..39782e4 100644 --- a/freon@UshakovVasilii_Github.yahoo.com/cpuUsageUtil.js +++ b/freon@UshakovVasilii_Github.yahoo.com/cpuUsageUtil.js @@ -46,23 +46,19 @@ export default class CpuUsageUtil { this._readings = []; - for (const [cpu, fields] of snapshot) { - const prev = this._prevSnapshot.get(cpu); - if (!prev) - continue; - + const fields = snapshot.get('cpu'); + const prev = this._prevSnapshot.get('cpu'); + if (fields && prev) { const idle = (fields.idle + fields.iowait) - (prev.idle + prev.iowait); const total = fields.total - prev.total; - if (total <= 0) - continue; - - const usage = 100.0 * (1.0 - idle / total); - - this._readings.push({ - label: cpu === 'cpu' ? 'CPU Total' : cpu.toUpperCase().replace('CPU', 'CPU '), - usage: Math.max(0, Math.min(100, usage)), - }); + if (total > 0) { + const usage = 100.0 * (1.0 - idle / total); + this._readings.push({ + label: 'CPU Usage', + usage: Math.max(0, Math.min(100, usage)), + }); + } } this._prevSnapshot = snapshot;