From 2ed0f3a259d80a02a5bd3521319e8bd8aa082301 Mon Sep 17 00:00:00 2001 From: MCHost Date: Mon, 14 Jul 2025 19:35:35 -0400 Subject: [PATCH] Container table CPU = 6 Cores RAM = GB --- status.html | 8 ++++---- system-status.js | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/status.html b/status.html index 74a7858..a17fde1 100644 --- a/status.html +++ b/status.html @@ -148,7 +148,7 @@ Name CPU Usage (%) - Memory Usage (MB) + Memory Usage (GB) State @@ -163,7 +163,7 @@ Name CPU Usage (%) - Memory Usage (MB) + Memory Usage (GB) State @@ -577,7 +577,7 @@ ${c.name} ${c.cpu}% - ${c.memory} MB + ${c.memory} GB ${c.state} `).join('') || ''; @@ -585,7 +585,7 @@ ${c.name} ${c.cpu}% - ${c.memory} MB + ${c.memory} GB ${c.state} `).join('') || ''; diff --git a/system-status.js b/system-status.js index 58237cc..c8c4202 100644 --- a/system-status.js +++ b/system-status.js @@ -80,14 +80,14 @@ async function getDockerStats() { const now = Date.now(); const timeDiffMs = now - prev.time; - // Calculate CPU usage as percentage of total CPU capacity + // Calculate CPU usage as percentage relative to the 6 cores limit let cpuUsage = 0; if (systemDelta > 0 && timeDiffMs > 0) { - cpuUsage = (cpuDelta / systemDelta) * stats.cpu_stats.online_cpus / TOTAL_CORES * 100; + cpuUsage = (cpuDelta / systemDelta) * (TOTAL_CORES / 6) * 100; } - // Memory usage - const memoryUsage = stats.memory_stats.usage / 1024 / 1024; // MB + // Memory usage in GB + const memoryUsage = (stats.memory_stats.usage / (1024 * 1024 * 1024)).toFixed(2); // Network stats const networkStats = stats.networks?.eth0 || { rx_bytes: 0, tx_bytes: 0 }; @@ -113,7 +113,7 @@ async function getDockerStats() { id: containerId.substring(0, 12), name: container.Names[0].replace(/^\//, ''), cpu: cpuUsage.toFixed(2), - memory: memoryUsage.toFixed(2), + memory: memoryUsage, network: { received: formatBytes(receivedRate), sent: formatBytes(sentRate) @@ -129,7 +129,7 @@ async function getDockerStats() { // Aggregate totals const totalCpu = containerStats.reduce((sum, c) => sum + parseFloat(c.cpu), 0).toFixed(2); - const totalMemory = (containerStats.reduce((sum, c) => sum + parseFloat(c.memory), 0) / 1024).toFixed(2); // Convert MB to GB + const totalMemory = containerStats.reduce((sum, c) => sum + parseFloat(c.memory), 0).toFixed(2); // Already in GB const totalNetwork = containerStats.reduce((sum, c) => ({ received: sum.received + parseFloat(c.network.received.value) * (c.network.received.unit === 'GB/s' ? 1e9 : c.network.received.unit === 'MB/s' ? 1e6 : c.network.received.unit === 'KB/s' ? 1e3 : 1), sent: sum.sent + parseFloat(c.network.sent.value) * (c.network.sent.unit === 'GB/s' ? 1e9 : c.network.sent.unit === 'MB/s' ? 1e6 : c.network.sent.unit === 'KB/s' ? 1e3 : 1)