Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

fix(hosts): calculate Used memory from Total-Free for host agents in LXC

rcourtmand389345153d6
diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.go
index b09e667fa7..327abd6cb2 100644
--- a/internal/monitoring/monitor.go
+++ b/internal/monitoring/monitor.go
@@ -2362,6 +2362,16 @@ func (m *Monitor) ApplyHostReport(report agentshost.Report, tokenRecord *config.
SwapTotal: report.Metrics.Memory.SwapTotal,
SwapUsed: report.Metrics.Memory.SwapUsed,
}
+
+ // Fallback for LXC environments: gopsutil may read Total and Free correctly
+ // from cgroup limits but return 0 for Used. Calculate Used from Total - Free.
+ if memory.Used <= 0 && memory.Total > 0 && memory.Free > 0 {
+ memory.Used = memory.Total - memory.Free
+ if memory.Used < 0 {
+ memory.Used = 0
+ }
+ }
+
if memory.Usage <= 0 && memory.Total > 0 {
memory.Usage = safePercentage(float64(memory.Used), float64(memory.Total))
}