From 497482aef34b3ba1e148ad34389fc2e838bab4b4 Mon Sep 17 00:00:00 2001 From: xtcnet Date: Sun, 8 Mar 2026 20:49:00 +0700 Subject: [PATCH] fix: WireGuard client filter, feat: system monitor storage and total ram --- backend/routes/reports.js | 13 ++++++++++++- frontend/src/components/SiteFooter.tsx | 18 +++++++++++++++--- frontend/src/pages/WireGuard/index.tsx | 2 +- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/backend/routes/reports.js b/backend/routes/reports.js index bff826f..f29a494 100644 --- a/backend/routes/reports.js +++ b/backend/routes/reports.js @@ -41,18 +41,29 @@ router .all(jwtdecode()) .get(async (req, res, next) => { try { - const [cpuTotal, memData, networkStats] = await Promise.all([ + const [cpuTotal, memData, networkStats, fsData] = await Promise.all([ si.currentLoad(), si.mem(), si.networkStats("*"), + si.fsSize() ]); // Grab eth0 or the first active interface const activeNet = networkStats.find(n => n.operstate === 'up' && n.iface !== 'lo') || networkStats[0] || {}; + // Summarize all detected physical drives to find total storage and used storage + const totalStorage = fsData.reduce((acc, disk) => acc + (disk.size || 0), 0); + const usedStorage = fsData.reduce((acc, disk) => acc + (disk.used || 0), 0); + const storagePercent = totalStorage > 0 ? Math.round((usedStorage / totalStorage) * 100) : 0; + res.status(200).json({ cpu: Math.round(cpuTotal.currentLoad), memory: Math.round((memData.active / memData.total) * 100), + memoryTotal: memData.total, + memoryActive: memData.active, + storage: storagePercent, + storageTotal: totalStorage, + storageUsed: usedStorage, networkRx: (activeNet.rx_sec / 1024 / 1024 * 8).toFixed(2), // Mbps networkTx: (activeNet.tx_sec / 1024 / 1024 * 8).toFixed(2), // Mbps }); diff --git a/frontend/src/components/SiteFooter.tsx b/frontend/src/components/SiteFooter.tsx index 728ae57..50dec26 100644 --- a/frontend/src/components/SiteFooter.tsx +++ b/frontend/src/components/SiteFooter.tsx @@ -1,11 +1,16 @@ import { useEffect, useState } from "react"; -import { IconCpu, IconServer, IconArrowsDownUp } from "@tabler/icons-react"; +import { IconCpu, IconServer, IconArrowsDownUp, IconDatabase } from "@tabler/icons-react"; import * as api from "../api/backend/base"; export function SiteFooter() { const [sysStats, setSysStats] = useState({ cpu: 0, memory: 0, + memoryTotal: 0, + memoryActive: 0, + storage: 0, + storageTotal: 0, + storageUsed: 0, networkRx: "0.00", networkTx: "0.00" }); @@ -35,6 +40,9 @@ export function SiteFooter() { }; }, []); + // Convert bytes to GB string + const formatGB = (bytes: number) => (bytes / 1024 / 1024 / 1024).toFixed(1); + return (