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: prefer status-mem over status-freemem for VM memory calculation

rcourtman902bdd92c21e
diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.go
index a0f65a848e..715bdf505a 100644
--- a/internal/monitoring/monitor.go
+++ b/internal/monitoring/monitor.go
@@ -6647,12 +6647,19 @@ func (m *Monitor) pollVMsAndContainersEfficient(ctx context.Context, instanceNam
memAvailable = memTotal
}
memUsed = memTotal - memAvailable
- case detailedStatus.FreeMem > 0 && memTotal >= detailedStatus.FreeMem:
- memUsed = memTotal - detailedStatus.FreeMem
- memorySource = "status-freemem"
case detailedStatus.Mem > 0:
+ // Prefer Mem over FreeMem: Proxmox calculates Mem as
+ // (total_mem - free_mem) using the balloon's guest-visible
+ // total, which is correct even when ballooning is active.
+ // FreeMem is relative to the balloon allocation (not MaxMem),
+ // so subtracting it from MaxMem produces wildly inflated
+ // usage when the balloon has reduced the VM's memory.
+ // Refs: #1185
memUsed = detailedStatus.Mem
memorySource = "status-mem"
+ case detailedStatus.FreeMem > 0 && memTotal >= detailedStatus.FreeMem:
+ memUsed = memTotal - detailedStatus.FreeMem
+ memorySource = "status-freemem"
}
if memUsed > memTotal {
memUsed = memTotal
diff --git a/internal/monitoring/monitor_polling.go b/internal/monitoring/monitor_polling.go
index ff672873cf..c417c6cb1f 100644
--- a/internal/monitoring/monitor_polling.go
+++ b/internal/monitoring/monitor_polling.go
@@ -364,12 +364,19 @@ func (m *Monitor) pollVMsWithNodes(ctx context.Context, instanceName string, clu
memAvailable = memTotal
}
memUsed = memTotal - memAvailable
- case vmStatus.FreeMem > 0:
- memUsed = memTotal - vmStatus.FreeMem
- memorySource = "status-freemem"
case vmStatus.Mem > 0:
+ // Prefer Mem over FreeMem: Proxmox calculates Mem as
+ // (total_mem - free_mem) using the balloon's guest-visible
+ // total, which is correct even when ballooning is active.
+ // FreeMem is relative to the balloon allocation (not MaxMem),
+ // so subtracting it from MaxMem produces wildly inflated
+ // usage when the balloon has reduced the VM's memory.
+ // Refs: #1185
memUsed = vmStatus.Mem
memorySource = "status-mem"
+ case vmStatus.FreeMem > 0:
+ memUsed = memTotal - vmStatus.FreeMem
+ memorySource = "status-freemem"
default:
memUsed = 0
memorySource = "status-unavailable"