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 monitored system status aggregation

rcourtman0c7a6ebf31e9
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 8bfd6cf48e..22d75f4cb5 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -193,6 +193,12 @@ source freshness state, including which source or surface degraded and the
corresponding last-seen timestamp. Billing and support surfaces must consume
that shared reason list instead of trying to infer why a fresh overall
`last_seen` can still coincide with warning status.
+That same status contract must choose the canonical monitored-system runtime
+status from the actual grouped top-level resources rather than from an
+implicit `unknown` baseline. Severity ordering is canonical: `offline`
+outranks `warning`, `warning` outranks `unknown`, and `unknown` outranks
+`online`, so all-online groups resolve online while any grouped offline view
+still wins over merely stale or warning surfaces.
That shared summary must also explain mixed-source freshness directly when one
grouped source reported more recently than the degraded one, so consumers do
not present a fresh `Last Seen` timestamp beside warning or offline state
diff --git a/internal/unifiedresources/monitored_systems.go b/internal/unifiedresources/monitored_systems.go
index 67b7b1d4cb..c03d416095 100644
--- a/internal/unifiedresources/monitored_systems.go
+++ b/internal/unifiedresources/monitored_systems.go
@@ -458,18 +458,28 @@ func monitoredSystemType(resource *Resource) string {
}
func monitoredSystemStatus(resources []*Resource) ResourceStatus {
- best := StatusUnknown
- bestPriority := monitoredSystemStatusPriority(best)
+ var (
+ best ResourceStatus
+ foundAny bool
+ )
for _, resource := range resources {
if resource == nil {
continue
}
+ if !foundAny {
+ best = resource.Status
+ foundAny = true
+ continue
+ }
priority := monitoredSystemStatusPriority(resource.Status)
+ bestPriority := monitoredSystemStatusPriority(best)
if priority < bestPriority {
best = resource.Status
- bestPriority = priority
}
}
+ if !foundAny {
+ return StatusUnknown
+ }
return best
}
@@ -815,9 +825,9 @@ func monitoredSystemStatusLastSeenSuffix(lastSeen time.Time) string {
func monitoredSystemStatusPriority(status ResourceStatus) int {
switch status {
- case StatusWarning:
- return 0
case StatusOffline:
+ return 0
+ case StatusWarning:
return 1
case StatusUnknown:
return 2
diff --git a/internal/unifiedresources/registry_test.go b/internal/unifiedresources/registry_test.go
index 44b7b64062..33ab844ad6 100644
--- a/internal/unifiedresources/registry_test.go
+++ b/internal/unifiedresources/registry_test.go
@@ -340,6 +340,97 @@ func TestMonitoredSystemsExplainsStaleGroupedSourceWhileLastSeenStaysFresh(t *te
}
}
+func TestMonitoredSystemsReportOnlineStatusWithoutUnknownBaselineBias(t *testing.T) {
+ rr := NewRegistry(nil)
+
+ proxmoxNode := topLevelTestProxmoxNode("proxmox-node", "tower", "proxmox-1", "https://tower.local:8006")
+ proxmoxNode.LastSeen = time.Date(2026, 3, 24, 10, 0, 0, 0, time.UTC)
+
+ rr.IngestRecords(SourceProxmox, []IngestRecord{
+ {
+ SourceID: "proxmox-node",
+ Resource: proxmoxNode,
+ },
+ })
+
+ systems := MonitoredSystems(rr)
+ if len(systems) != 1 {
+ t.Fatalf("MonitoredSystems() returned %d systems, want 1", len(systems))
+ }
+ if systems[0].Status != StatusOnline {
+ t.Fatalf("MonitoredSystems()[0].Status = %q, want %q", systems[0].Status, StatusOnline)
+ }
+ if systems[0].StatusExplanation.Summary != "All included top-level collection paths currently report online status." {
+ t.Fatalf("unexpected online status summary: %q", systems[0].StatusExplanation.Summary)
+ }
+}
+
+func TestMonitoredSystemsGroupedOnlineSourcesStayOnline(t *testing.T) {
+ rr := NewRegistry(nil)
+ now := time.Date(2026, 3, 24, 10, 0, 0, 0, time.UTC)
+
+ agentResource := topLevelTestAgent("agent-host", "tower.local", "machine-1", "agent-1")
+ agentResource.LastSeen = now.Add(-1 * time.Minute)
+
+ dockerResource := topLevelTestDockerHost("docker-host", "tower.local", "docker-runtime-1", "agent-1")
+ dockerResource.LastSeen = now
+
+ rr.IngestRecords(SourceAgent, []IngestRecord{
+ {
+ SourceID: "agent-host",
+ Resource: agentResource,
+ },
+ })
+ rr.IngestRecords(SourceDocker, []IngestRecord{
+ {
+ SourceID: "docker-host",
+ Resource: dockerResource,
+ },
+ })
+
+ systems := MonitoredSystems(rr)
+ if len(systems) != 1 {
+ t.Fatalf("MonitoredSystems() returned %d systems, want 1", len(systems))
+ }
+ if systems[0].Status != StatusOnline {
+ t.Fatalf("MonitoredSystems()[0].Status = %q, want %q", systems[0].Status, StatusOnline)
+ }
+}
+
+func TestMonitoredSystemsPreferOfflineOverWarning(t *testing.T) {
+ rr := NewRegistry(nil)
+ now := time.Date(2026, 3, 24, 10, 0, 0, 0, time.UTC)
+
+ agentResource := topLevelTestAgent("agent-host", "tower.local", "machine-1", "agent-1")
+ agentResource.Status = StatusWarning
+ agentResource.LastSeen = now.Add(-1 * time.Minute)
+
+ dockerResource := topLevelTestDockerHost("docker-host", "tower.local", "docker-runtime-1", "agent-1")
+ dockerResource.Status = StatusOffline
+ dockerResource.LastSeen = now
+
+ rr.IngestRecords(SourceAgent, []IngestRecord{
+ {
+ SourceID: "agent-host",
+ Resource: agentResource,
+ },
+ })
+ rr.IngestRecords(SourceDocker, []IngestRecord{
+ {
+ SourceID: "docker-host",
+ Resource: dockerResource,
+ },
+ })
+
+ systems := MonitoredSystems(rr)
+ if len(systems) != 1 {
+ t.Fatalf("MonitoredSystems() returned %d systems, want 1", len(systems))
+ }
+ if systems[0].Status != StatusOffline {
+ t.Fatalf("MonitoredSystems()[0].Status = %q, want %q", systems[0].Status, StatusOffline)
+ }
+}
+
func TestResourceRegistry_IngestRecords_UnknownSource(t *testing.T) {
rr := NewRegistry(nil)
now := time.Date(2026, 2, 20, 12, 0, 0, 0, time.UTC)