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 CPU calculation on systemUsage counter reset

rcourtmanb5798012fc20
diff --git a/internal/dockeragent/agent.go b/internal/dockeragent/agent.go
index 7c2f3a9159..942e4a0714 100644
--- a/internal/dockeragent/agent.go
+++ b/internal/dockeragent/agent.go
@@ -1377,9 +1377,9 @@ func (a *Agent) calculateContainerCPUPercent(id string, stats containertypes.Sta
var systemDelta float64
if current.systemUsage >= prev.systemUsage {
systemDelta = float64(current.systemUsage - prev.systemUsage)
- } else if current.systemUsage > 0 {
- systemDelta = float64(current.systemUsage)
}
+ // If systemUsage went backward (counter reset), leave systemDelta as 0
+ // to fall through to time-based calculation below
if systemDelta > 0 {
cpuPercent := safeFloat((totalDelta / systemDelta) * float64(onlineCPUs) * 100.0)