From 79779d6fcf8fc532c326158571bc44ada15d93c1 Mon Sep 17 00:00:00 2001 From: CN-JS-HuiBai Date: Sat, 4 Apr 2026 22:53:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8B=E7=BA=BF=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/prometheus-service.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/prometheus-service.js b/server/prometheus-service.js index 3f772b4..616ff78 100644 --- a/server/prometheus-service.js +++ b/server/prometheus-service.js @@ -279,6 +279,8 @@ async function getOverviewMetrics(url, sourceName) { } } + const activeInstances = Array.from(instances.values()).filter(inst => inst.up); + // Aggregate let totalCpuUsed = 0, totalCpuCores = 0; let totalMemUsed = 0, totalMemTotal = 0; @@ -286,7 +288,7 @@ async function getOverviewMetrics(url, sourceName) { let totalNetRx = 0, totalNetTx = 0; let totalTraffic24hRx = 0, totalTraffic24hTx = 0; - for (const inst of instances.values()) { + for (const inst of activeInstances) { totalCpuUsed += (inst.cpuPercent / 100) * inst.cpuCores; totalCpuCores += inst.cpuCores; totalMemUsed += inst.memUsed; @@ -306,7 +308,7 @@ async function getOverviewMetrics(url, sourceName) { } return { - totalServers: instances.size, + totalServers: activeInstances.length, cpu: { used: totalCpuUsed, total: totalCpuCores, @@ -332,7 +334,7 @@ async function getOverviewMetrics(url, sourceName) { tx: totalTraffic24hTx, total: totalTraffic24hRx + totalTraffic24hTx }, - servers: Array.from(instances.values()).map(s => { + servers: activeInstances.map(s => { const { originalInstance, ...rest } = s; return rest; })