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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Key previous Proxmox nodes by source ID so poll carry-overs match
rcourtman0c130a4855e4
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.mdindex 40873c0536..ba87140d89 100644--- a/docs/release-control/v6/internal/subsystems/monitoring.md+++ b/docs/release-control/v6/internal/subsystems/monitoring.md@@ -3772,7 +3772,39 @@ cluster sensor cache, which keeps its own recency check. When every sourcereturns nothing, `internal/monitoring/monitor_polling_node_helpers.go` may carrya previous reading, with its original `LastUpdate`, only inside the carry window(twice the PVE polling interval, never under five minutes); an older reading is-dropped rather than re-presented as current.+dropped rather than re-presented as current. A carried reading also keeps a+lapsed host agent's lease. Agent readings are stamped with the agent's report+time, so `carriedTemperatureOutlivesAgentLease` drops a carried reading stamped+no later than the last report of the node's matched agent (by link, then+hostname, whether or not that report had sensors) once that agent has lapsed.+Readings record no source, so the bound is conservative: an SSH, cluster-cache+or agent-plus-SSH merged reading (stamped with the agent's time) of that age is+dropped too, being already older than the lease, while a reading stamped after+that report keeps the carry window. A carried reading (`carriedNodeTemperature`)+keeps only the node's CPU and GPU temperatures: its SMART and NVMe rows would+also stamp the node's physical disks, whose freshness and standby state a+carried copy cannot follow (a disk that spun down would be stamped and recorded+with its pre-sleep value), so they are left out, and nothing is carried when+only they remain.+The poller reads its previous poll's nodes back from the unified read state+through `internal/monitoring/monitor_previous_state.go`. `nodeLastOnline` and+the temperature carry with its CPU low/record tracking match them by node ID,+which is the Proxmox source ID, so the projection must return+`NodeView.SourceID()`, never the unified resource ID, and carry the stored+`TemperatureDetails`. Nodes preserved through an instance outage+(`preserveOrExpireNodes`) or authoritative membership reconciliation are written+back into state from that projection, so it also restores the identity inputs+the registry derives a node's canonical ID and cross-view merges from: cluster+name, provider-scoped flag, native aliases, TLS fingerprint and linked agent ID,+the config-derived ones stamped the way `pollPVENode` stamps them. With the+unified ID a node re-keys on every failed poll, and without its cluster+identity a cluster member changes canonical ID for the length of an outage.+A preserved node keeps its+temperature only under the same carry rules and loses it when it goes+offline. Node memory carry-over after a failed status read uses the poller's own+validated `NodeMemorySnapshot`, not the read state, which holds the agent's+reading on a node merged with a host agent, and keeps used, cache and free+summing to the total.Legacy SSH temperature collection must also use the Pulse sensor-wrappercontract before falling back to raw lm-sensors output. `internal/monitoring/temperature.go`must request `/usr/local/sbin/pulse-sensors` when it exists, parse the wrapperdiff --git a/internal/monitoring/host_agent_temps.go b/internal/monitoring/host_agent_temps.goindex 661caeaf6e..8b3fc4d3e0 100644--- a/internal/monitoring/host_agent_temps.go+++ b/internal/monitoring/host_agent_temps.go@@ -86,44 +86,7 @@ func (m *Monitor) getHostAgentTemperatureByID(nodeID, nodeName string) *models.Treturn nil}- hosts := readState.Hosts()- if len(hosts) == 0 {- // No host agents at all — check cluster sensor cache as fallback- return m.getClusterSensorTemperature(nodeName)- }-- var matchedHost *unifiedresources.HostView-- // First, try to find a host agent that is explicitly linked to this node- // via LinkedNodeID. This is the most reliable method and handles duplicate- // hostnames correctly.- if nodeID != "" {- for i := range hosts {- if hosts[i].LinkedNodeID() == nodeID {- matchedHost = hosts[i]- log.Debug().- Str("nodeID", nodeID).- Str("hostAgentID", hosts[i].ID()).- Str("hostname", hosts[i].Hostname()).- Msg("Matched host agent to node via LinkedNodeID")- break- }- }- }-- // Fallback: match by hostname if no linked host was found- // This maintains backwards compatibility for setups where linking hasn't occurred yet- if matchedHost == nil {- nodeLower := strings.ToLower(strings.TrimSpace(nodeName))- for i := range hosts {- hostnameLower := strings.ToLower(strings.TrimSpace(hosts[i].Hostname()))- if hostnameLower == nodeLower {- matchedHost = hosts[i]- break- }- }- }-+ matchedHost := hostAgentForNode(readState.Hosts(), nodeID, nodeName)if matchedHost == nil {// No directly-linked host agent found — check cluster sensor cachereturn m.getClusterSensorTemperature(nodeName)@@ -153,6 +116,68 @@ func (m *Monitor) getHostAgentTemperatureByID(nodeID, nodeName string) *models.Treturn convertUnifiedHostSensorsToTemperature(sensors, agentStatus.LastSeen)}+// carriedTemperatureOutlivesAgentLease reports whether a temperature a node+// carries over from an earlier poll may have come from the node's host agent+// after that agent stopped reporting. Agent readings are stamped with the+// agent's report time and only count inside its reporting lease, so a reading+// stamped no later than a lapsed agent's last report is treated as the agent's+// and is not carried. Readings carry no source, so an SSH or cluster-cache+// reading of that age is dropped too; it is already older than the lease, and+// the bound errs toward a gap rather than a stale value. A reading stamped+// after that report keeps the ordinary carry window.+func (m *Monitor) carriedTemperatureOutlivesAgentLease(nodeID, nodeName string, temp *models.Temperature, now time.Time) bool {+ if temp == nil {+ return false+ }+ readState := m.GetUnifiedReadStateOrSnapshot()+ if readState == nil {+ return false+ }+ matchedHost := hostAgentForNode(readState.Hosts(), nodeID, nodeName)+ if matchedHost == nil {+ return false+ }+ agentStatus, ok := matchedHost.SourceStatus(unifiedresources.SourceAgent)+ if !ok || agentStatus.LastSeen.IsZero() ||+ hostAgentReportCurrent(agentStatus.LastSeen, matchedHost.IntervalSeconds(), now) {+ return false+ }+ return !temp.LastUpdate.After(agentStatus.LastSeen)+}++// hostAgentForNode returns the host agent for a Proxmox node: the agent linked+// to the node ID, else one whose hostname matches. This correctly handles+// clusters where multiple nodes may have the same hostname (e.g., "px1" on+// different IPs).+func hostAgentForNode(hosts []*unifiedresources.HostView, nodeID, nodeName string) *unifiedresources.HostView {+ // First, try to find a host agent that is explicitly linked to this node+ // via LinkedNodeID. This is the most reliable method and handles duplicate+ // hostnames correctly.+ if nodeID != "" {+ for i := range hosts {+ if hosts[i].LinkedNodeID() == nodeID {+ log.Debug().+ Str("nodeID", nodeID).+ Str("hostAgentID", hosts[i].ID()).+ Str("hostname", hosts[i].Hostname()).+ Msg("Matched host agent to node via LinkedNodeID")+ return hosts[i]+ }+ }+ }++ // Fallback: match by hostname if no linked host was found+ // This maintains backwards compatibility for setups where linking hasn't occurred yet+ nodeLower := strings.ToLower(strings.TrimSpace(nodeName))+ for i := range hosts {+ hostnameLower := strings.ToLower(strings.TrimSpace(hosts[i].Hostname()))+ if hostnameLower == nodeLower {+ return hosts[i]+ }+ }+ return nil+}+func convertUnifiedHostSensorsToTemperature(sensors *unifiedresources.HostSensorMeta, lastSeen time.Time) *models.Temperature {if sensors == nil {return nildiff --git a/internal/monitoring/memory_trust_characterization_test.go b/internal/monitoring/memory_trust_characterization_test.goindex 60c583c3a1..366164e81d 100644--- a/internal/monitoring/memory_trust_characterization_test.go+++ b/internal/monitoring/memory_trust_characterization_test.go@@ -203,7 +203,7 @@ func TestPollPVENodeMemoryTrustCharacterization(t *testing.T) {MaxCPU: 8,}- modelNode, _, _, err := mon.pollPVENode(context.Background(), "test", &mon.config.PVEInstances[0], client, node, "healthy", nil, nil)+ modelNode, _, _, err := mon.pollPVENode(context.Background(), "test", &mon.config.PVEInstances[0], client, node, "healthy", nil)if err != nil {t.Fatalf("pollPVENode() error = %v", err)}@@ -258,7 +258,7 @@ func TestPollPVENodePreservesPreviousSnapshotDuringTransientFallback(t *testing.MaxCPU: 8,}- first, _, _, err := mon.pollPVENode(context.Background(), "test", &mon.config.PVEInstances[0], client, node, "healthy", nil, nil)+ first, _, _, err := mon.pollPVENode(context.Background(), "test", &mon.config.PVEInstances[0], client, node, "healthy", nil)if err != nil {t.Fatalf("first pollPVENode() error = %v", err)}@@ -274,7 +274,6 @@ func TestPollPVENodePreservesPreviousSnapshotDuringTransientFallback(t *testing.client,node,"healthy",- map[string]models.Memory{first.ID: first.Memory},nil,)if err != nil {@@ -302,7 +301,6 @@ func TestPollPVENodePreservesPreviousSnapshotDuringTransientFallback(t *testing.client,node,"healthy",- map[string]models.Memory{second.ID: second.Memory},nil,)if err != nil {diff --git a/internal/monitoring/monitor_additional_test.go b/internal/monitoring/monitor_additional_test.goindex bc771e5d42..6a9b566dae 100644--- a/internal/monitoring/monitor_additional_test.go+++ b/internal/monitoring/monitor_additional_test.go@@ -1158,3 +1158,430 @@ func TestTenantDeletionWaitsForSlowMonitoringLoop(t *testing.T) {}mtm.FinishTenantDeletion("deletion")}++// The poller reads the previous poll's nodes back through the unified read+// state. Those lookups key on the Proxmox source ID, so the projection must+// return it (not the registry's unified resource ID) and carry the stored+// temperature; otherwise the node's CPU low/record values reset to the+// current reading every poll and a failed collection never carries over.+func TestPreviousNodeProjectionFeedsPollerTemperatureTracking(t *testing.T) {+ instanceCfg := config.PVEInstance{Name: "pve1", Host: "https://10.0.0.1:8006"}+ adapter := unifiedresources.NewMonitorAdapter(unifiedresources.NewRegistry(nil))+ m := &Monitor{+ config: &config.Config{TemperatureMonitoringEnabled: true, PVEInstances: []config.PVEInstance{instanceCfg}},+ state: models.NewState(),+ resourceStore: adapter,+ }+ base := models.Node{ID: "pve1-node1", NodeIdentity: "pve1-node1", Name: "node1", Instance: "pve1", Status: "online", Type: "node"}++ // publish rebuilds the unified store from state the way the monitor does,+ // alongside the host agents' latest reports.+ var hosts []models.Host+ publish := func() {+ snapshot := m.state.GetSnapshot()+ snapshot.Hosts = hosts+ adapter.PopulateFromSnapshot(snapshot)+ }+ // poll delivers an agent report (none when agentReading is 0), runs one PVE+ // poll's temperature step against the previous poll's nodes, and publishes+ // the polled node.+ poll := func(agentReading float64) *models.Temperature {+ t.Helper()+ hosts = nil+ if agentReading > 0 {+ hosts = []models.Host{{+ ID: "agent-1", Hostname: "node1", Status: "online", LinkedNodeID: base.ID, IntervalSeconds: 30, LastSeen: time.Now(),+ Sensors: models.HostSensorSummary{TemperatureCelsius: map[string]float64{"cpu_package": agentReading}},+ }}+ }+ publish()+ prevNodes := m.snapshotPrevNodes("pve1")+ polled := base+ polled.LastSeen = time.Now()+ m.collectNodeTemperatureData(context.Background(), "pve1", &instanceCfg, proxmox.Node{Node: "node1"}, &polled, prevNodes, "online")+ m.state.UpdateNodesForInstance("pve1", []models.Node{polled})+ publish()+ return polled.Temperature+ }++ if temp := poll(50); temp == nil || temp.CPUMin != 50 || temp.CPUMaxRecord != 50 {+ t.Fatalf("first reading = %#v, want min and record initialised to 50", temp)+ }+ prevNodes := m.snapshotPrevNodes("pve1")+ if len(prevNodes) != 1 || prevNodes[0].ID != base.ID || prevNodes[0].Temperature == nil {+ t.Fatalf("previous nodes = %#v, want source ID %q with its temperature", prevNodes, base.ID)+ }++ if temp := poll(62); temp == nil || temp.CPUPackage != 62 || temp.CPUMin != 50 || temp.CPUMaxRecord != 62 {+ t.Fatalf("second reading = %#v, want current 62, low 50, record 62", temp)+ }+ third := poll(45)+ if third == nil || third.CPUPackage != 45 || third.CPUMin != 45 || third.CPUMaxRecord != 62 {+ t.Fatalf("third reading = %#v, want current 45, low 45, record 62", third)+ }++ // No agent and no SSH collector: the last reading carries over with its+ // original timestamp, inside the carry window.+ carried := poll(0)+ if carried == nil || carried.CPUPackage != 45 || !carried.LastUpdate.Equal(third.LastUpdate) {+ t.Fatalf("carried reading = %#v, want the previous 45 with its original timestamp", carried)+ }+}++// When a whole Proxmox instance stops answering, its last-known nodes are+// written back into state through the offline grace policy. That writeback+// must keep each node the same resource: the poller's source ID and the+// config-derived identity the registry derives a cluster member's canonical ID+// from. Past grace the node goes offline and stops presenting a temperature.+func TestPVEOutageWritebackKeepsNodeIdentity(t *testing.T) {+ for _, tc := range []struct {+ name string+ instances []config.PVEInstance+ wantID string+ providerScoped bool+ }{+ {+ name: "cluster member",+ instances: []config.PVEInstance{{Name: "pve-a", Host: "https://10.0.0.1:8006", IsCluster: true, ClusterName: "lab"}},+ wantID: "lab-node1",+ },+ {+ name: "cluster name shared by two connections",+ instances: []config.PVEInstance{+ {Name: "pve-a", Host: "https://10.0.0.1:8006", IsCluster: true, ClusterName: "lab"},+ {Name: "pve-b", Host: "https://10.0.1.1:8006", IsCluster: true, ClusterName: "lab"},+ },+ wantID: "pve-a-node1",+ providerScoped: true,+ },+ } {+ t.Run(tc.name, func(t *testing.T) {+ adapter := unifiedresources.NewMonitorAdapter(unifiedresources.NewRegistry(nil))+ m := &Monitor{+ config: &config.Config{PVEInstances: tc.instances},+ state: models.NewState(),+ resourceStore: adapter,+ nodeLastOnline: make(map[string]time.Time),+ }+ instanceCfg := m.getInstanceConfig("pve-a")+ if got := m.pveNodeID("pve-a", instanceCfg, "node1"); got != tc.wantID {+ t.Fatalf("pveNodeID = %q, want %q", got, tc.wantID)+ }+ now := time.Now()+ polled := m.placeholderNodeForInstance("pve-a", instanceCfg, "node1")+ polled.Status = "online"+ polled.ConnectionHealth = "healthy"+ polled.LastSeen = now+ polled.Temperature = &models.Temperature{CPUPackage: 55, Available: true, HasCPU: true, LastUpdate: now}+ if polled.ProviderScopedIdentity != tc.providerScoped {+ t.Fatalf("ProviderScopedIdentity = %v, want %v", polled.ProviderScopedIdentity, tc.providerScoped)+ }+ m.nodeLastOnline[polled.ID] = now+ m.state.UpdateNodesForInstance("pve-a", []models.Node{polled})+ adapter.PopulateFromSnapshot(m.state.GetSnapshot())+ unifiedID := adapter.Nodes()[0].ID()++ for cycle := 0; cycle < 3; cycle++ {+ m.markPVEInstanceNodesUnreachable("pve-a")+ adapter.PopulateFromSnapshot(m.state.GetSnapshot())+ stateNodes := m.state.GetSnapshot().Nodes+ if len(stateNodes) != 1 || stateNodes[0].ID != tc.wantID || stateNodes[0].ClusterName != "lab" ||+ stateNodes[0].ProviderScopedIdentity != tc.providerScoped {+ t.Fatalf("cycle %d: state nodes = %#v, want %q kept with its cluster identity", cycle, stateNodes, tc.wantID)+ }+ if stateNodes[0].Status != "online" || stateNodes[0].Temperature == nil {+ t.Fatalf("cycle %d: node within grace = %#v, want online with its recent temperature", cycle, stateNodes[0])+ }+ if nodes := adapter.Nodes(); len(nodes) != 1 || nodes[0].ID() != unifiedID {+ t.Fatalf("cycle %d: unified nodes = %v, want the single resource %q", cycle, nodes, unifiedID)+ }+ }++ // The process last saw the node online beyond the grace period.+ m.nodeLastOnline[polled.ID] = now.Add(-2 * nodeOfflineGracePeriod)+ polled.LastSeen = now.Add(-2 * nodeOfflineGracePeriod)+ m.state.UpdateNodesForInstance("pve-a", []models.Node{polled})+ adapter.PopulateFromSnapshot(m.state.GetSnapshot())+ m.markPVEInstanceNodesUnreachable("pve-a")+ adapter.PopulateFromSnapshot(m.state.GetSnapshot())+ expired := m.state.GetSnapshot().Nodes+ if len(expired) != 1 || expired[0].ID != tc.wantID || expired[0].Status != "offline" || expired[0].Temperature != nil {+ t.Fatalf("expired nodes = %#v, want %q offline without a temperature", expired, tc.wantID)+ }+ if nodes := adapter.Nodes(); len(nodes) != 1 || nodes[0].ID() != unifiedID {+ t.Fatalf("unified nodes after expiry = %v, want the single resource %q", nodes, unifiedID)+ }+ })+ }+}++// Within grace a preserved node keeps its temperature only while the reading+// is inside the same carry window a failed collection gets.+func TestPreserveOrExpireNodesBoundsGraceTemperature(t *testing.T) {+ m := &Monitor{config: &config.Config{}, state: models.NewState(), nodeLastOnline: make(map[string]time.Time)}+ now := time.Now()+ m.nodeLastOnline["pve-node1"] = now+ stale := now.Add(-m.nodeTemperatureCarryWindow() - time.Minute)+ preserved := m.preserveOrExpireNodes([]models.Node{{+ ID: "pve-node1", Name: "node1", Status: "online", LastSeen: now,+ Temperature: &models.Temperature{CPUPackage: 70, Available: true, LastUpdate: stale},+ }})+ if len(preserved) != 1 || preserved[0].Status != "online" || preserved[0].Temperature != nil {+ t.Fatalf("preserved = %#v, want online within grace without the stale temperature", preserved)+ }+}++// When detailed node status fails, the poller may carry its own last trusted+// memory reading for one cycle. On a node merged with a host agent, the read+// state holds the agent's memory, which is not the Proxmox value the snapshot+// vouches for, so the carry must use the snapshot and keep its used, cache+// and free split summing to the total.+func TestPollPVENodeCarriesOwnMemorySnapshot(t *testing.T) {+ t.Setenv("PULSE_DATA_DIR", t.TempDir())+ const gib = uint64(1024 * 1024 * 1024)++ mon := newTestPVEMonitor("test")+ defer mon.alertManager.Stop()+ defer mon.notificationMgr.Stop()+ adapter := unifiedresources.NewMonitorAdapter(unifiedresources.NewRegistry(nil))+ mon.resourceStore = adapter++ client := &stubPVEClient{nodeStatus: &proxmox.NodeStatus{+ Memory: &proxmox.MemoryStatus{Total: 16 * gib, Used: 12 * gib, Free: 1 * gib, Available: 8 * gib},+ }}+ node := proxmox.Node{Node: "node1", Status: "online", MaxMem: 16 * gib, Mem: 15 * gib, MaxCPU: 8}++ first, _, _, err := mon.pollPVENode(context.Background(), "test", &mon.config.PVEInstances[0], client, node, "healthy", nil)+ if err != nil {+ t.Fatalf("first pollPVENode() error = %v", err)+ }+ if !first.Memory.HasKnownUsage() || first.Memory.Used != int64(8*gib) || first.Memory.Cache == 0 {+ t.Fatalf("first.Memory = %+v, want 8 GiB used with reclaimable cache split out", first.Memory)+ }+ mon.state.UpdateNodesForInstance("test", []models.Node{first})+ snapshot := mon.state.GetSnapshot()+ snapshot.Hosts = []models.Host{{+ ID: "agent-1", Hostname: "node1", Status: "online", LinkedNodeID: first.ID, IntervalSeconds: 30, LastSeen: time.Now(),+ Memory: models.Memory{Total: int64(16 * gib), Used: int64(3 * gib), Free: int64(13 * gib), Usage: 18.75},+ }}+ adapter.PopulateFromSnapshot(snapshot)++ client.nodeStatus = nil+ second, _, _, err := mon.pollPVENode(context.Background(), "test", &mon.config.PVEInstances[0], client, node, "healthy", mon.snapshotPrevNodes("test"))+ if err != nil {+ t.Fatalf("second pollPVENode() error = %v", err)+ }+ if second.Memory.Used != first.Memory.Used || second.Memory.Cache != first.Memory.Cache || second.Memory.Free != first.Memory.Free {+ t.Fatalf("second.Memory = %+v, want the poller's own reading %+v", second.Memory, first.Memory)+ }+ if second.Memory.Used+second.Memory.Cache+second.Memory.Free != second.Memory.Total {+ t.Fatalf("second.Memory = %+v, want used + cache + free = total", second.Memory)+ }+ if snap := mon.nodeSnapshots[makeNodeSnapshotKey("test", "node1")]; snap.MemorySource != "previous-snapshot" {+ t.Fatalf("snapshot.MemorySource = %q, want previous-snapshot", snap.MemorySource)+ }+}++// Authoritative cluster membership writes previous nodes back too. Read from+// the unified store, an offline member keeps its source ID and agent link but+// stops presenting a temperature, and a member missing from /nodes keeps a+// reading only inside the carry window.+func TestPVEMembershipReconcileKeepsPreviousNodeIdentity(t *testing.T) {+ cfg := &config.Config{PVEInstances: []config.PVEInstance{{+ Name: "cluster-api", Host: "https://pve-a:8006", IsCluster: true, ClusterName: "production",+ }}}+ m := newUnreachableTestMonitor(t, cfg)+ adapter := unifiedresources.NewMonitorAdapter(unifiedresources.NewRegistry(nil))+ m.resourceStore = adapter+ instanceCfg := &cfg.PVEInstances[0]+ now := time.Now()+ polled := func(name string, tempAge time.Duration) models.Node {+ node := m.placeholderNodeForInstance("cluster-api", instanceCfg, name)+ node.Status = "online"+ node.ConnectionHealth = "healthy"+ node.LastSeen = now+ node.Temperature = &models.Temperature{CPUPackage: 60, Available: true, HasCPU: true, LastUpdate: now.Add(-tempAge)}+ return node+ }+ offlineMember := polled("pve-a", 0)+ offlineMember.LinkedAgentID = "agent-pve-a"+ m.state.UpdateNodesForInstance("cluster-api", []models.Node{+ offlineMember, polled("pve-b", 0), polled("pve-c", m.nodeTemperatureCarryWindow()+time.Minute),+ })+ adapter.PopulateFromSnapshot(m.state.GetSnapshot())++ client := &membershipPVEClient{statuses: []proxmox.ClusterStatus{+ {Type: "cluster", Name: "production", Quorate: 1},+ {Type: "node", Name: "pve-a", Online: 0},+ {Type: "node", Name: "pve-b", Online: 1},+ {Type: "node", Name: "pve-c", Online: 1},+ }}+ got := pveNodeByName(m.reconcilePVENodeInventory(+ context.Background(), "cluster-api", instanceCfg, client, nil, m.snapshotPrevNodes("cluster-api"),+ ))++ if node := got["pve-a"]; node.ID != "production-pve-a" || node.Status != "offline" || node.Temperature != nil || node.LinkedAgentID != "agent-pve-a" {+ t.Fatalf("offline member = %#v, want production-pve-a offline with its agent link and no temperature", node)+ }+ if node := got["pve-b"]; node.ID != "production-pve-b" || node.Status != "unknown" || node.Temperature == nil {+ t.Fatalf("unobserved member = %#v, want production-pve-b unknown with its recent temperature", node)+ }+ if node := got["pve-c"]; node.ID != "production-pve-c" || node.Status != "unknown" || node.Temperature != nil {+ t.Fatalf("unobserved member = %#v, want production-pve-c unknown without its stale temperature", node)+ }++ // Writing the reconciled inventory back keeps every member the same+ // unified resource.+ unifiedIDs := func() map[string]string {+ ids := make(map[string]string)+ for _, node := range adapter.Nodes() {+ ids[node.NodeName()] = node.ID()+ }+ return ids+ }+ before := unifiedIDs()+ m.state.UpdateNodesForInstance("cluster-api", sortedPVENodeInventory(got))+ adapter.PopulateFromSnapshot(m.state.GetSnapshot())+ if after := unifiedIDs(); len(after) != 3 || after["pve-a"] != before["pve-a"] || after["pve-b"] != before["pve-b"] || after["pve-c"] != before["pve-c"] {+ t.Fatalf("unified IDs after writeback = %v, want %v", after, before)+ }+}++// A temperature carried over from an earlier poll keeps a lapsed host agent's+// lease: a reading the agent supplied (stamped no later than its last report)+// is dropped once the agent stops reporting, even when its latest report had+// no sensors, while a reading taken after that report keeps the carry window.+// The same rule bounds what an instance outage preserves within node grace.+func TestNodeTemperatureCarryRespectsAgentLease(t *testing.T) {+ now := time.Now()+ silentSince := now.Add(-hostAgentHealthWindow(30) - time.Minute)+ instanceCfg := config.PVEInstance{Name: "pve1", Host: "https://10.0.0.1:8006"}+ base := models.Node{ID: "pve1-node1", NodeIdentity: "pve1-node1", Name: "node1", Instance: "pve1", Status: "online", Type: "node", LastSeen: now}++ for _, tc := range []struct {+ name string+ readingAt time.Time+ agentSensors bool+ wantCarried bool+ }{+ {name: "reading from the silent agent", readingAt: silentSince, agentSensors: true},+ {name: "silent agent whose last report had no sensors", readingAt: silentSince.Add(-30 * time.Second)},+ {name: "SSH reading taken after the agent went silent", readingAt: now.Add(-time.Minute), agentSensors: true, wantCarried: true},+ } {+ t.Run(tc.name, func(t *testing.T) {+ adapter := unifiedresources.NewMonitorAdapter(unifiedresources.NewRegistry(nil))+ m := &Monitor{+ config: &config.Config{TemperatureMonitoringEnabled: true, PVEInstances: []config.PVEInstance{instanceCfg}},+ state: models.NewState(),+ resourceStore: adapter,+ nodeLastOnline: map[string]time.Time{base.ID: now},+ }+ agent := models.Host{ID: "agent-1", Hostname: "node1", Status: "offline", LinkedNodeID: base.ID, IntervalSeconds: 30, LastSeen: silentSince}+ if tc.agentSensors {+ agent.Sensors = models.HostSensorSummary{TemperatureCelsius: map[string]float64{"cpu_package": 92}}+ }+ published := base+ published.Temperature = &models.Temperature{CPUPackage: 92, CPUMin: 92, CPUMaxRecord: 92, Available: true, HasCPU: true, LastUpdate: tc.readingAt}+ m.state.UpdateNodesForInstance("pve1", []models.Node{published})+ snapshot := m.state.GetSnapshot()+ snapshot.Hosts = []models.Host{agent}+ adapter.PopulateFromSnapshot(snapshot)++ polled := base+ m.collectNodeTemperatureData(context.Background(), "pve1", &instanceCfg, proxmox.Node{Node: "node1"}, &polled, m.snapshotPrevNodes("pve1"), "online")+ if carried := polled.Temperature != nil; carried != tc.wantCarried {+ t.Fatalf("failed collection carried = %v (%#v), want %v", carried, polled.Temperature, tc.wantCarried)+ }++ preserved := m.preserveOrExpireNodes(m.snapshotPrevNodes("pve1"))+ if len(preserved) != 1 || preserved[0].Status != "online" {+ t.Fatalf("preserved = %#v, want the node online within grace", preserved)+ }+ if kept := preserved[0].Temperature != nil; kept != tc.wantCarried {+ t.Fatalf("outage preservation kept temperature = %v, want %v", kept, tc.wantCarried)+ }+ })+ }+}++// A carried node reading keeps the node's CPU temperature steady through a+// failed collection, but never its disk temperatures: those also stamp the+// node's physical disks, which have their own freshness and standby state.+// Here a current agent whose only sensor is a SMART disk reports that disk in+// standby, so collection returns nothing; the disk must not be re-stamped with+// its pre-sleep reading through the carry.+func TestCarriedNodeTemperatureLeavesDiskReadingsOut(t *testing.T) {+ now := time.Now()+ instanceCfg := config.PVEInstance{Name: "pve1", Host: "https://10.0.0.1:8006"}+ base := models.Node{ID: "pve1-node1", NodeIdentity: "pve1-node1", Name: "node1", Instance: "pve1", Status: "online", Type: "node", LastSeen: now}+ disk := models.PhysicalDisk{ID: "pve1-node1-sda", Node: "node1", Instance: "pve1", DevPath: "/dev/sda", Serial: "WD-STANDBY", Type: "hdd"}++ for _, tc := range []struct {+ name string+ previous models.Temperature+ wantCPU bool+ }{+ {+ name: "CPU and disk reading",+ previous: models.Temperature{+ Available: true, HasCPU: true, CPUPackage: 50, HasSMART: true, HasNVMe: true,+ SMART: []models.DiskTemp{{Device: "/dev/sda", Serial: "WD-STANDBY", Temperature: 38}},+ NVMe: []models.NVMeTemp{{Device: "nvme0", Temp: 44}},+ },+ wantCPU: true,+ },+ {+ name: "disk-only reading",+ previous: models.Temperature{+ Available: true, HasSMART: true,+ SMART: []models.DiskTemp{{Device: "/dev/sda", Serial: "WD-STANDBY", Temperature: 38}},+ },+ },+ } {+ t.Run(tc.name, func(t *testing.T) {+ adapter := unifiedresources.NewMonitorAdapter(unifiedresources.NewRegistry(nil))+ m := &Monitor{+ config: &config.Config{TemperatureMonitoringEnabled: true, PVEInstances: []config.PVEInstance{instanceCfg}},+ state: models.NewState(),+ resourceStore: adapter,+ nodeLastOnline: map[string]time.Time{base.ID: now},+ }+ published := base+ previous := tc.previous+ previous.LastUpdate = now.Add(-time.Minute)+ published.Temperature = &previous+ m.state.UpdateNodesForInstance("pve1", []models.Node{published})+ snapshot := m.state.GetSnapshot()+ snapshot.Hosts = []models.Host{{+ ID: "agent-1", Hostname: "node1", Status: "online", LinkedNodeID: base.ID, IntervalSeconds: 30, LastSeen: now,+ Sensors: models.HostSensorSummary{SMART: []models.HostDiskSMART{{Device: "sda", Serial: "WD-STANDBY", Standby: true}}},+ }}+ adapter.PopulateFromSnapshot(snapshot)++ polled := base+ m.collectNodeTemperatureData(context.Background(), "pve1", &instanceCfg, proxmox.Node{Node: "node1"}, &polled, m.snapshotPrevNodes("pve1"), "online")+ if tc.wantCPU {+ if polled.Temperature == nil || polled.Temperature.CPUPackage != 50 || !polled.Temperature.LastUpdate.Equal(previous.LastUpdate) {+ t.Fatalf("carried temperature = %#v, want CPU 50 with its original timestamp", polled.Temperature)+ }+ if len(polled.Temperature.SMART) != 0 || len(polled.Temperature.NVMe) != 0 || polled.Temperature.HasSMART || polled.Temperature.HasNVMe {+ t.Fatalf("carried temperature kept disk readings: %#v", polled.Temperature)+ }+ } else if polled.Temperature != nil {+ t.Fatalf("carried temperature = %#v, want none when only disk readings were left", polled.Temperature)+ }+ if stamped := mergeNVMeTempsIntoDisks([]models.PhysicalDisk{disk}, []models.Node{polled}); stamped[0].Temperature != 0 {+ t.Fatalf("standby disk stamped with %d°C from a carried reading, want no reading", stamped[0].Temperature)+ }++ // Outage preservation follows the same rule.+ preserved := m.preserveOrExpireNodes(m.snapshotPrevNodes("pve1"))+ if len(preserved) != 1 {+ t.Fatalf("preserved = %#v, want one node", preserved)+ }+ if got := preserved[0].Temperature; (got != nil) != tc.wantCPU || (got != nil && (len(got.SMART) != 0 || len(got.NVMe) != 0)) {+ t.Fatalf("preserved temperature = %#v, want CPU only (%v)", got, tc.wantCPU)+ }+ })+ }+}diff --git a/internal/monitoring/monitor_alert_handling_test.go b/internal/monitoring/monitor_alert_handling_test.goindex 8ecdeb2250..1e84d90190 100644--- a/internal/monitoring/monitor_alert_handling_test.go+++ b/internal/monitoring/monitor_alert_handling_test.go@@ -1547,22 +1547,24 @@ func TestSilentLinkedAgentStopsRefreshingNodeTemperatureAlert(t *testing.T) {alertConfig.NodeDefaults.Temperature = &alerts.HysteresisThreshold{Trigger: 80, Clear: 75}manager.UpdateConfig(alertConfig)- registry := unifiedresources.NewRegistry(nil)+ adapter := unifiedresources.NewMonitorAdapter(unifiedresources.NewRegistry(nil))monitor := &Monitor{config: &config.Config{TemperatureMonitoringEnabled: true},state: models.NewState(),- resourceStore: unifiedresources.NewMonitorAdapter(registry),+ resourceStore: adapter,}node := models.Node{ID: "pve1-node1", Name: "node1", Instance: "pve1", Status: "online",ConnectionHealth: "healthy", LinkedAgentID: "agent-1",}- // ingest records a PVE poll that just saw the node, plus the agent as of its- // last report.+ // ingest rebuilds the store, as each monitor refresh does, from the last PVE+ // poll's node (with the temperature it published, which the next poll reads+ // back as its previous node) plus the agent as of its last report.+ lastPolled := nodeingest := func(agentLastReport time.Time, agentStatus string) {- polledNode := node+ polledNode := lastPolledpolledNode.LastSeen = time.Now()- registry.IngestSnapshot(models.StateSnapshot{+ adapter.PopulateFromSnapshot(models.StateSnapshot{Nodes: []models.Node{polledNode},Hosts: []models.Host{{ID: "agent-1", Hostname: "node1", Status: agentStatus, LinkedNodeID: node.ID,@@ -1574,13 +1576,14 @@ func TestSilentLinkedAgentStopsRefreshingNodeTemperatureAlert(t *testing.T) {// poll runs the node temperature step of a PVE poll (no SSH collector) and// evaluates the node's alerts with the result.poll := func() *models.Temperature {- _, prevNodes := monitor.snapshotPrevNodes("pve1")+ prevNodes := monitor.snapshotPrevNodes("pve1")polled := nodemonitor.collectNodeTemperatureData(context.Background(), "pve1", &config.PVEInstance{Name: "pve1"}, proxmox.Node{Node: node.Name},&polled, prevNodes, "online",)manager.CheckNode(polled)+ lastPolled = polledreturn polled.Temperature}temperatureAlert := func() alerts.Alert {@@ -1605,8 +1608,15 @@ func TestSilentLinkedAgentStopsRefreshingNodeTemperatureAlert(t *testing.T) {opened := temperatureAlert()// The agent goes silent while PVE polling continues: the merged row stays- // fresh, but the agent's retained sensors no longer count as a reading.- ingest(time.Now().Add(-hostAgentHealthWindow(30)-time.Minute), "offline")+ // fresh, but the agent's retained sensors no longer count as a reading, and+ // the poller does not carry the agent's last reading past its lease. With no+ // clock to advance, age the agent's last report and the reading it produced+ // by the same amount.+ silence := hostAgentHealthWindow(30) + time.Minute+ agedReading := *lastPolled.Temperature+ agedReading.LastUpdate = agedReading.LastUpdate.Add(-silence)+ lastPolled.Temperature = &agedReading+ ingest(agentReport.Add(-silence), "offline")time.Sleep(5 * time.Millisecond)require.Nil(t, poll(), "a silent agent's retained sensors must not be presented as a current reading")held := temperatureAlert()diff --git a/internal/monitoring/monitor_extra_coverage_test.go b/internal/monitoring/monitor_extra_coverage_test.goindex 4060fc88cc..23caafd87e 100644--- a/internal/monitoring/monitor_extra_coverage_test.go+++ b/internal/monitoring/monitor_extra_coverage_test.go@@ -2132,22 +2132,32 @@ func TestMonitor_PreviousNodesForInstance_Extra(t *testing.T) {registry := unifiedresources.NewRegistry(nil)registry.IngestSnapshot(models.StateSnapshot{Nodes: []models.Node{- {ID: "node-1", Instance: "pve1", Name: "a", DisplayName: "a", Memory: models.Memory{Total: 100}},+ {+ ID: "node-1", Instance: "pve1", Name: "a", DisplayName: "a", ClusterName: "lab",+ Memory: models.Memory{Total: 100, Used: 40, Free: 60, Usage: 40},+ Temperature: &models.Temperature{CPUPackage: 52, CPUMin: 41, CPUMaxRecord: 70, Available: true, HasCPU: true},+ },{ID: "node-2", Instance: "pve2", Name: "b", DisplayName: "b", Memory: models.Memory{Total: 200}},},})m.resourceStore = unifiedresources.NewMonitorAdapter(registry)- prevNodeMemory, prevNodes := m.previousNodesForInstance("pve1")+ prevNodes := m.previousNodesForInstance("pve1")if len(prevNodes) != 1 || prevNodes[0].Instance != "pve1" || prevNodes[0].DisplayName != "a" {t.Fatalf("expected only pve1 nodes, got %#v", prevNodes)}- if mem, ok := prevNodeMemory[prevNodes[0].ID]; !ok || mem.Total != 100 {- t.Fatalf("expected node memory for node-1, got %#v", prevNodeMemory)+ // The poller matches previous nodes by its own source ID, never the+ // registry's unified resource ID.+ if prevNodes[0].ID != "node-1" || prevNodes[0].NodeIdentity != "node-1" {+ t.Fatalf("previous node ID = %q / identity %q, want source ID node-1", prevNodes[0].ID, prevNodes[0].NodeIdentity)+ }+ if prevNodes[0].ClusterName != "lab" || prevNodes[0].Memory.Total != 100 || prevNodes[0].Memory.Used != 40 {+ t.Fatalf("previous node lost cluster or memory: %#v", prevNodes[0])}- if len(prevNodeMemory) != 1 {- t.Fatalf("expected node-2 to be filtered out, got %#v", prevNodeMemory)+ temp := prevNodes[0].Temperature+ if temp == nil || temp.CPUPackage != 52 || temp.CPUMin != 41 || temp.CPUMaxRecord != 70 {+ t.Fatalf("previous node temperature = %#v, want the stored reading with its min/max records", temp)}}diff --git a/internal/monitoring/monitor_memory_test.go b/internal/monitoring/monitor_memory_test.goindex df2a659a1b..84042d56fd 100644--- a/internal/monitoring/monitor_memory_test.go+++ b/internal/monitoring/monitor_memory_test.go@@ -366,6 +366,11 @@ func TestPollPVEInstanceMarksStaleNodesOfflineWhenGetNodesReturnsEmpty(t *testinstaleNode := first.Nodes[0]staleNode.LastSeen = time.Now().Add(-nodeOfflineGracePeriod - 2*time.Second)mon.state.UpdateNodesForInstance("test", []models.Node{staleNode})+ // The grace policy also counts this process's own online sighting, keyed+ // by the node's source ID, so age that too.+ mon.mu.Lock()+ mon.nodeLastOnline[staleNode.ID] = staleNode.LastSeen+ mon.mu.Unlock()client.nodes = nilmon.pollPVEInstance(context.Background(), "test", client)diff --git a/internal/monitoring/monitor_polling_node.go b/internal/monitoring/monitor_polling_node.goindex 035897cdc3..a2b301f63a 100644--- a/internal/monitoring/monitor_polling_node.go+++ b/internal/monitoring/monitor_polling_node.go@@ -96,26 +96,31 @@ func collectPVENodeNetworkInterfaces(return mapPVENodeNetworkInterfaces(interfaces)}-func (m *Monitor) canCarryForwardNodeMemory(instance, node string, now time.Time) bool {+// carryForwardNodeMemory returns the node's last memory reading from this+// poller's own snapshot when that reading came from a trusted source recently+// enough to stand in for one failed status read. The unified read state is not+// used here: on a node merged with a host agent it holds the agent's reading,+// not the Proxmox value this snapshot vouches for.+func (m *Monitor) carryForwardNodeMemory(instance, node string, now time.Time) (models.Memory, bool) {if m == nil {- return false+ return models.Memory{}, false}m.diagMu.RLock()snapshot, ok := m.nodeSnapshots[makeNodeSnapshotKey(instance, node)]m.diagMu.RUnlock()if !ok || !snapshot.Memory.HasKnownUsage() || snapshot.RetrievedAt.IsZero() {- return false+ return models.Memory{}, false}age := now.Sub(snapshot.RetrievedAt)if age < 0 || age > nodeMemoryCarryForwardMaxAge {- return false+ return models.Memory{}, false}switch CanonicalMemorySource(snapshot.MemorySource) {case "available-field", "derived-free-buffers-cached", "derived-total-minus-used","rrd-memavailable", "rrd-memused":- return true+ return snapshot.Memory, truedefault:- return false+ return models.Memory{}, false}}@@ -126,7 +131,6 @@ func (m *Monitor) pollPVENode(client PVEClientInterface,node proxmox.Node,connectionHealthStr string,- prevNodeMemory map[string]models.Memory,prevInstanceNodes []models.Node,) (models.Node, string, string, error) {nodeStart := time.Now()@@ -314,10 +318,8 @@ func (m *Monitor) pollPVENode(}// If we couldn't update memory metrics using detailed status, preserve previous accurate values if available- if !memoryUpdated &&- effectiveStatus == "online" &&- m.canCarryForwardNodeMemory(instanceName, node.Node, time.Now()) {- if prevMem, exists := prevNodeMemory[modelNode.ID]; exists && prevMem.HasKnownUsage() {+ if !memoryUpdated && effectiveStatus == "online" {+ if prevMem, ok := m.carryForwardNodeMemory(instanceName, node.Node, time.Now()); ok {total := int64(node.MaxMem)if total == 0 {total = prevMem.Total@@ -326,14 +328,14 @@ func (m *Monitor) pollPVENode(if total > 0 && used > total {used = total}- free := total - used- if free < 0 {- free = 0- }+ // Keep the snapshot's used | cache | free split summing to total.+ cache := min(max(prevMem.Cache, 0), max(total-used, 0))+ free := max(total-used-cache, 0)preserved := prevMempreserved.Total = totalpreserved.Used = used+ preserved.Cache = cachepreserved.Free = freepreserved.Usage = safePercentage(float64(used), float64(total))diff --git a/internal/monitoring/monitor_polling_node_helpers.go b/internal/monitoring/monitor_polling_node_helpers.goindex ced65961a2..e8ef1e849a 100644--- a/internal/monitoring/monitor_polling_node_helpers.go+++ b/internal/monitoring/monitor_polling_node_helpers.go@@ -331,7 +331,15 @@ func (m *Monitor) collectNodeTemperatureData(}}- if prevTemp != nil && time.Since(prevTemp.LastUpdate) > m.nodeTemperatureCarryWindow() {+ if m.carriedTemperatureOutlivesAgentLease(modelNode.ID, node.Node, prevTemp, time.Now()) {+ // The reading came from a host agent that has stopped reporting.+ // Its reporting lease already rode out transient gaps, so+ // carrying it would outlive that lease.+ log.Debug().+ Str("node", node.Node).+ Time("lastUpdate", prevTemp.LastUpdate).+ Msg("Dropped temperature data (host agent stopped reporting)")+ } else if prevTemp != nil && time.Since(prevTemp.LastUpdate) > m.nodeTemperatureCarryWindow() {// Collection has stayed broken past the carry window. Re-presenting// the old reading would let alerts, history and the UI treat it as// a live measurement forever, so the node has no reading now.@@ -340,11 +348,9 @@ func (m *Monitor) collectNodeTemperatureData(Bool("isCluster", modelNode.IsClusterMember).Time("lastUpdate", prevTemp.LastUpdate).Msg("Dropped stale temperature data (collection has not returned a reading within the carry window)")- } else if prevTemp != nil {- // Clone the previous temperature to avoid modifying historical data- preserved := *prevTemp- preserved.LastUpdate = prevTemp.LastUpdate // Keep original update time to indicate staleness- modelNode.Temperature = &preserved+ } else if preserved := carriedNodeTemperature(prevTemp); preserved != nil {+ // The carried copy keeps its original LastUpdate to indicate staleness.+ modelNode.Temperature = preservedlog.Debug().Str("node", node.Node).Bool("isCluster", modelNode.IsClusterMember).@@ -361,6 +367,30 @@ func (m *Monitor) collectNodeTemperatureData(}}+// carriedNodeTemperature returns the part of an earlier reading a node may+// keep presenting while collection fails: its CPU and GPU temperatures, with+// the original LastUpdate. Disk temperatures (SMART, NVMe) are left out. They+// also stamp the node's physical disks, which have their own freshness and+// standby state that a carried copy cannot follow: a disk that spun down would+// be stamped, and recorded, with its pre-sleep reading. Returns nil when the+// earlier reading held nothing else.+func carriedNodeTemperature(prev *models.Temperature) *models.Temperature {+ if prev == nil || !prev.Available {+ return nil+ }+ carried := *prev+ carried.Cores = append([]models.CoreTemp(nil), prev.Cores...)+ carried.GPU = append([]models.GPUTemp(nil), prev.GPU...)+ carried.SMART = []models.DiskTemp{}+ carried.HasSMART = false+ carried.NVMe = []models.NVMeTemp{}+ carried.HasNVMe = false+ if !hasUsableTemperatureReading(&carried) {+ return nil+ }+ return &carried+}+func (m *Monitor) applyNodePendingUpdates(ctx context.Context, instanceName string, client PVEClientInterface, node proxmox.Node, nodeID string, effectiveStatus string, modelNode *models.Node) {if modelNode == nil {returndiff --git a/internal/monitoring/monitor_previous_state.go b/internal/monitoring/monitor_previous_state.goindex bfd30496c9..79568436ef 100644--- a/internal/monitoring/monitor_previous_state.go+++ b/internal/monitoring/monitor_previous_state.go@@ -3,6 +3,7 @@ package monitoringimport ("strings"+ "github.com/rcourtman/pulse-go-rewrite/internal/config""github.com/rcourtman/pulse-go-rewrite/internal/models""github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources")@@ -89,24 +90,31 @@ func (m *Monitor) previousGuestContextForInstance(instanceName string) previousGreturn ctx}-func (m *Monitor) previousNodesForInstance(instanceName string) (map[string]models.Memory, []models.Node) {- prevNodeMemory := make(map[string]models.Memory)+func (m *Monitor) previousNodesForInstance(instanceName string) []models.Node {prevInstanceNodes := make([]models.Node, 0)readState := m.GetUnifiedReadStateOrSnapshot()if readState == nil {- return prevNodeMemory, prevInstanceNodes+ return prevInstanceNodes}+ // The registry keeps no copy of the identity stamps pollPVENode derives+ // from configuration, so restore them the same way. Nodes preserved through+ // an instance outage are written back to state, and without these the+ // registry would derive a different canonical identity for them.+ instanceCfg := m.getInstanceConfig(instanceName)+ providerScoped := m.pveNodeUsesProviderScopedIdentity(instanceName, instanceCfg)for _, existingNode := range readState.Nodes() {if existingNode == nil || existingNode.Instance() != instanceName {continue}modelNode := previousNodeFromView(existingNode)- prevNodeMemory[modelNode.ID] = modelNode.Memory+ modelNode.ProviderScopedIdentity = providerScoped+ modelNode.NativeNameAliases = config.PVEClusterNodeNativeAliases(instanceCfg, modelNode.Name)+ modelNode.TLSFingerprint = pveNodeTLSFingerprint(instanceCfg, modelNode.Name)prevInstanceNodes = append(prevInstanceNodes, modelNode)}- return prevNodeMemory, prevInstanceNodes+ return prevInstanceNodes}func previousVMFromView(vm *unifiedresources.VMView) models.VM {@@ -199,20 +207,33 @@ func previousNodeFromView(node *unifiedresources.NodeView) models.Node {if node == nil {return models.Node{}}+ // The poller keys nodes by their Proxmox source ID (nodeLastOnline, the+ // temperature carry, state writes). The unified resource ID is a separate+ // registry key, so returning it would match nothing, and writing it back+ // during an outage would re-key the node on every failed poll.+ id := node.SourceID()+ if id == "" {+ id = node.ID()+ }return models.Node{- ID: node.ID(),+ ID: id,+ NodeIdentity: id,Name: node.NodeName(),DisplayName: node.Name(),Instance: node.Instance(),Host: node.HostURL(),Status: string(node.Status()),+ Type: "node",Uptime: node.Uptime(),IsClusterMember: node.IsClusterMember(),+ ClusterName: node.ClusterName(),LastSeen: node.LastSeen(),LoadAverage: node.LoadAverage(),PVEVersion: node.PVEVersion(),KernelVersion: node.KernelVersion(),NetworkInterfaces: hostNetworkInterfacesFromReadStateView(node.NetworkInterfaces()),+ Temperature: node.TemperatureDetails(),+ LinkedAgentID: node.LinkedAgentID(),Memory: models.Memory{Used: node.MemoryUsed(),Total: node.MemoryTotal(),diff --git a/internal/monitoring/monitor_pve.go b/internal/monitoring/monitor_pve.goindex 1394b9a20d..7f5405f896 100644--- a/internal/monitoring/monitor_pve.go+++ b/internal/monitoring/monitor_pve.go@@ -587,7 +587,7 @@ func (m *Monitor) updatePVEConnectionHealth(ctx context.Context, instanceName streturn connectionHealthStr}-func (m *Monitor) snapshotPrevNodes(instanceName string) (map[string]models.Memory, []models.Node) {+func (m *Monitor) snapshotPrevNodes(instanceName string) []models.Node {return m.previousNodesForInstance(instanceName)}@@ -598,7 +598,6 @@ func (m *Monitor) pollPVENodesParallel(client PVEClientInterface,nodes []proxmox.Node,connectionHealthStr string,- prevNodeMemory map[string]models.Memory,prevInstanceNodes []models.Node,debugEnabled bool,) ([]models.Node, map[string]string, map[string]string) {@@ -627,7 +626,7 @@ func (m *Monitor) pollPVENodesParallel(go func(node proxmox.Node) {defer wg.Done()- modelNode, effectiveStatus, diskSource, _ := m.pollPVENode(ctx, instanceName, instanceCfg, client, node, connectionHealthStr, prevNodeMemory, prevInstanceNodes)+ modelNode, effectiveStatus, diskSource, _ := m.pollPVENode(ctx, instanceName, instanceCfg, client, node, connectionHealthStr, prevInstanceNodes)resultChan <- nodePollResult{node: modelNode,@@ -655,7 +654,7 @@ func (m *Monitor) pollPVENodesParallel(// leaves the last successful snapshot in state forever, so a shut-down host// keeps showing its final online status (#1441).func (m *Monitor) markPVEInstanceNodesUnreachable(instanceName string) {- _, prevInstanceNodes := m.snapshotPrevNodes(instanceName)+ prevInstanceNodes := m.snapshotPrevNodes(instanceName)if len(prevInstanceNodes) == 0 {// Never polled successfully this process lifetime (e.g. Pulse// started while the host was already down). Synthesize offline@@ -762,6 +761,7 @@ func (m *Monitor) preserveOrExpireNodes(prevInstanceNodes []models.Node) []modelif nodeCopy.ConnectionHealth == "" || strings.EqualFold(nodeCopy.ConnectionHealth, "error") {nodeCopy.ConnectionHealth = "degraded"}+ m.boundCarriedNodeTemperature(&nodeCopy, now)preserved = append(preserved, nodeCopy)continue}@@ -770,11 +770,28 @@ func (m *Monitor) preserveOrExpireNodes(prevInstanceNodes []models.Node) []modelnodeCopy.ConnectionHealth = "error"nodeCopy.Uptime = 0nodeCopy.CPU = 0+ nodeCopy.Temperature = nilpreserved = append(preserved, nodeCopy)}return preserved}+// boundCarriedNodeTemperature applies the rules a failed live collection's+// carry follows to a temperature a node keeps from an earlier poll: the carry+// window, a lapsed host agent's lease for a reading that agent supplied, and+// no disk temperatures (carriedNodeTemperature).+func (m *Monitor) boundCarriedNodeTemperature(node *models.Node, now time.Time) {+ if node.Temperature == nil {+ return+ }+ if now.Sub(node.Temperature.LastUpdate) > m.nodeTemperatureCarryWindow() ||+ m.carriedTemperatureOutlivesAgentLease(node.ID, node.Name, node.Temperature, now) {+ node.Temperature = nil+ return+ }+ node.Temperature = carriedNodeTemperature(node.Temperature)+}+func (m *Monitor) seedNodeDisplayNames(modelNodes []models.Node) {for i := range modelNodes {if modelNodes[i].DisplayName != "" {@@ -1466,8 +1483,9 @@ func (m *Monitor) pollPVEInstance(ctx context.Context, instanceName string, clie// Check if client is a ClusterClient to determine health statusconnectionHealthStr := m.updatePVEConnectionHealth(ctx, instanceName, client)- // Capture previous memory metrics so we can preserve them if detailed status fails- prevNodeMemory, prevInstanceNodes := m.snapshotPrevNodes(instanceName)+ // Capture the previous poll's nodes for network, temperature and+ // inventory continuity when this poll cannot read them.+ prevInstanceNodes := m.snapshotPrevNodes(instanceName)// Convert to modelsmodelNodes, nodeEffectiveStatus, nodeDiskSources := m.pollPVENodesParallel(@@ -1477,7 +1495,6 @@ func (m *Monitor) pollPVEInstance(ctx context.Context, instanceName string, clieclient,nodes,connectionHealthStr,- prevNodeMemory,prevInstanceNodes,debugEnabled,)diff --git a/internal/monitoring/monitor_pve_cluster.go b/internal/monitoring/monitor_pve_cluster.goindex 083948619f..d03383f925 100644--- a/internal/monitoring/monitor_pve_cluster.go+++ b/internal/monitoring/monitor_pve_cluster.go@@ -431,11 +431,13 @@ func (m *Monitor) reconcilePVENodeInventory(node.ConnectionHealth = "error"node.CPU = 0node.Uptime = 0+ node.Temperature = nil} else if _, observed := currentByName[key]; !observed {node.Status = "unknown"node.ConnectionHealth = "degraded"node.CPU = 0node.Uptime = 0+ m.boundCarriedNodeTemperature(&node, time.Now())}reconciled[key] = node}diff --git a/internal/monitoring/node_memory_sources_test.go b/internal/monitoring/node_memory_sources_test.goindex 70687c67d0..5e93730088 100644--- a/internal/monitoring/node_memory_sources_test.go+++ b/internal/monitoring/node_memory_sources_test.go@@ -242,7 +242,6 @@ func TestPollPVENodePrefersLinkedHostDiskOverRootFS(t *testing.T) {},"healthy",nil,- nil,)if err != nil {t.Fatalf("pollPVENode() error = %v", err)