From 8537b6fbbf0e8b847be1d29befae31a01d0e4959 Mon Sep 17 00:00:00 2001 From: CorentinMre <72888555+CorentinMre@users.noreply.github.com> Date: Sun, 12 Oct 2025 11:59:31 +0200 Subject: [PATCH 1/2] fix: use actual memory usage excluding cache/buffers in monitoring - Replace v.Used with (Total - Available) calculation - Provides accurate memory usage for monitoring alerts - Prevents false alerts caused by Linux cache/buffers - Aligns with 'free -h' available memory metric --- apps/monitoring/monitoring/monitor.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/monitoring/monitoring/monitor.go b/apps/monitoring/monitoring/monitor.go index 0beb4320f..eef1e5d85 100644 --- a/apps/monitoring/monitoring/monitor.go +++ b/apps/monitoring/monitoring/monitor.go @@ -130,7 +130,8 @@ func GetServerMetrics() database.ServerMetric { } memTotalGB := float64(v.Total) / 1024 / 1024 / 1024 - memUsedGB := float64(v.Used) / 1024 / 1024 / 1024 + memAvailableGB := float64(v.Available) / 1024 / 1024 / 1024 + memUsedGB := memTotalGB - memAvailableGB memUsedPercent := (memUsedGB / memTotalGB) * 100 var networkIn, networkOut float64 From b200ed6a73990261bd32bf9579e4f14402a541f6 Mon Sep 17 00:00:00 2001 From: CorentinMre <72888555+CorentinMre@users.noreply.github.com> Date: Sun, 12 Oct 2025 16:36:19 +0200 Subject: [PATCH 2/2] fix: update CPU usage calculation to use a one-second interval --- apps/monitoring/monitoring/monitor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/monitoring/monitoring/monitor.go b/apps/monitoring/monitoring/monitor.go index eef1e5d85..2567f286b 100644 --- a/apps/monitoring/monitoring/monitor.go +++ b/apps/monitoring/monitoring/monitor.go @@ -117,7 +117,7 @@ func getRealOS() string { func GetServerMetrics() database.ServerMetric { v, _ := mem.VirtualMemory() - c, _ := cpu.Percent(0, false) + c, _ := cpu.Percent(time.Second, false) cpuInfo, _ := cpu.Info() diskInfo, _ := disk.Usage("/") netInfo, _ := net.IOCounters(false)