mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-03 18:43:38 +01:00
The Proxmox page warns when a node's SSH temperature monitoring still runs the pre-rc.6 setup, which locks the key to `sensors -j` so SATA/SAS disk temperatures never arrive. The notice judged that from the disk rows of the active tab, and since each tab hydrates only its own resource families, Overview loads no disks and never showed it. The registry now derives the verdict on the node itself, after child counts resolve each disk's canonical parent: a node with an available, legacy-format temperature payload is flagged when a SMART-only disk under it has no reading collected now. The page lists flagged nodes from the rows every tab already loads, so Overview needs no disk inventory. Every Proxmox node carries an explicit true or false, because the browser merges a facet field by field and would keep an earlier true if a cleared verdict were omitted. Two rule fixes ride along with the move. Proxmox's own disk inventory types SATA/SAS disks as hdd or ssd, so the old sata/sas-only set never matched a node without a host agent. And a retained reading kept after a disk stopped being read no longer counts as present (diskinventory.TemperatureCollected).
80 lines
3.2 KiB
Go
80 lines
3.2 KiB
Go
package unifiedresources
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/rcourtman/pulse-go-rewrite/pkg/diskinventory"
|
|
)
|
|
|
|
// smartTemperatureDiskTypes are the disk types whose temperature reaches a
|
|
// Proxmox node only through SMART: the transports a host agent or the
|
|
// pulse-sensors wrapper reports (sata, sas) and the form factors Proxmox's own
|
|
// disk inventory reports for those same disks (hdd, ssd). Proxmox also types
|
|
// a non-rotational USB device ssd. NVMe temperatures come from kernel hwmon
|
|
// and arrive even on a legacy setup.
|
|
var smartTemperatureDiskTypes = map[string]struct{}{
|
|
"sata": {},
|
|
"sas": {},
|
|
"hdd": {},
|
|
"ssd": {},
|
|
}
|
|
|
|
// refreshProxmoxSensorSetupLocked derives ProxmoxData.SensorSetupOutdated on
|
|
// every Proxmox node, as an explicit true or false. SSH temperature monitoring
|
|
// set up before v6.0.0-rc.6 locks the node's key to `sensors -j`: the payload
|
|
// still parses and carries CPU and NVMe temperatures, but SMART disk
|
|
// temperatures can never arrive, so they stay blank with no error anywhere.
|
|
// The flag is data-gated three ways: the node's last temperature collection
|
|
// succeeded, its payload was the legacy format, and a disk under it waits on a
|
|
// SMART temperature it does not have now. A last known temperature kept for a
|
|
// disk that could not be read now (standby, a host agent past its lease) is not
|
|
// a current one (diskinventory.TemperatureCollected), while a disk whose
|
|
// temperature arrives another way, such as a linked host agent, falls out.
|
|
// Disks count through their canonical parent, so an agent the registry has not
|
|
// linked to the node contributes none. Deriving the flag here lets every
|
|
// surface that lists nodes read it without loading the node's disk inventory.
|
|
// It must run after buildChildCounts, which resolves each disk's canonical
|
|
// parent node.
|
|
func (rr *ResourceRegistry) refreshProxmoxSensorSetupLocked() {
|
|
waiting := make(map[string]struct{})
|
|
for _, resource := range rr.resources {
|
|
if resource == nil {
|
|
continue
|
|
}
|
|
if resource.Proxmox != nil {
|
|
// A fresh pointer every time: a facet copied by an earlier merge or
|
|
// clone must not see this generation's verdict.
|
|
resource.Proxmox.SensorSetupOutdated = nil
|
|
if CanonicalResourceType(resource.Type) == ResourceTypeAgent {
|
|
resource.Proxmox.SensorSetupOutdated = sensorSetupVerdict(false)
|
|
}
|
|
}
|
|
if resource.ParentID != nil && physicalDiskWaitsOnSMARTTemperature(resource) {
|
|
waiting[*resource.ParentID] = struct{}{}
|
|
}
|
|
}
|
|
for parentID := range waiting {
|
|
node := rr.resources[parentID]
|
|
if node == nil || node.Proxmox == nil || CanonicalResourceType(node.Type) != ResourceTypeAgent {
|
|
continue
|
|
}
|
|
details := node.Proxmox.TemperatureDetails
|
|
node.Proxmox.SensorSetupOutdated = sensorSetupVerdict(details != nil && details.Available && details.LegacySensorsFormat)
|
|
}
|
|
}
|
|
|
|
func sensorSetupVerdict(outdated bool) *bool {
|
|
return &outdated
|
|
}
|
|
|
|
func physicalDiskWaitsOnSMARTTemperature(resource *Resource) bool {
|
|
if CanonicalResourceType(resource.Type) != ResourceTypePhysicalDisk || resource.PhysicalDisk == nil {
|
|
return false
|
|
}
|
|
disk := resource.PhysicalDisk
|
|
if _, ok := smartTemperatureDiskTypes[strings.ToLower(strings.TrimSpace(disk.DiskType))]; !ok {
|
|
return false
|
|
}
|
|
return !diskinventory.TemperatureCollected(disk.Temperature, disk.Collection)
|
|
}
|