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(docker): calculate Used memory from Total-Free in Docker-in-LXC

rcourtman4090d98160f1
diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.go
index fbd976449d..b09e667fa7 100644
--- a/internal/monitoring/monitor.go
+++ b/internal/monitoring/monitor.go
@@ -2040,6 +2040,20 @@ func (m *Monitor) ApplyDockerReport(report agentsdocker.Report, tokenRecord *con
memory.Total = report.Host.TotalMemoryBytes
}
+ // Additional fallback for Docker-in-LXC: gopsutil may read Total and Free
+ // correctly from cgroup limits but return 0 for Used. Calculate Used from
+ // Total - Free when this happens. This fixes the "0B / 7GB" display issue.
+ if memory.Used <= 0 && memory.Total > 0 && memory.Free > 0 {
+ memory.Used = memory.Total - memory.Free
+ if memory.Used < 0 {
+ memory.Used = 0
+ }
+ // Recalculate usage percentage
+ if memory.Total > 0 {
+ memory.Usage = safePercentage(float64(memory.Used), float64(memory.Total))
+ }
+ }
+
disks := make([]models.Disk, 0, len(report.Host.Disks))
for _, disk := range report.Host.Disks {
disks = append(disks, models.Disk{