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.

Name the agent disk history key apart from its source ID

rcourtman400d62ca04f6
diff --git a/internal/monitoring/canonical_guardrails_test.go b/internal/monitoring/canonical_guardrails_test.go
index 8a13f8b631..e2110c7103 100644
--- a/internal/monitoring/canonical_guardrails_test.go
+++ b/internal/monitoring/canonical_guardrails_test.go
@@ -2075,7 +2075,7 @@ func TestHostPhysicalDiskIOMetricsUseCanonicalDiskHistoryPath(t *testing.T) {
requiredSnippets := []string{
"m.writeHostPhysicalDiskIOMetrics(host, now)",
"func (m *Monitor) writeHostPhysicalDiskIOMetrics(host models.Host, now time.Time) {",
- `resourceID := unifiedresources.HostSMARTDiskSourceID(host, disk)`,
+ `resourceID := unifiedresources.HostSMARTDiskMetricID(host, disk)`,
`m.metricsHistory.AddDiskMetric(resourceID, "diskread", readRate, now)`,
`m.metricsStore.Write("disk", resourceID, "diskwrite", writeRate, now)`,
`m.metricsStore.Write("disk", resourceID, "disk", busyPct, now)`,
diff --git a/internal/monitoring/issue1595_collection_trust_test.go b/internal/monitoring/issue1595_collection_trust_test.go
index 7a52f71d8b..494133db65 100644
--- a/internal/monitoring/issue1595_collection_trust_test.go
+++ b/internal/monitoring/issue1595_collection_trust_test.go
@@ -362,7 +362,7 @@ func TestWriteHostSMARTMetricsRecordsOnlyCollectedTemperatures(t *testing.T) {
{host.Sensors.SMART[3], 0},
{host.Sensors.SMART[4], 0},
} {
- id := unifiedresources.HostSMARTDiskSourceID(host, tc.disk)
+ id := unifiedresources.HostSMARTDiskMetricID(host, tc.disk)
points, err := store.Query("disk", id, "smart_temp", now.Add(-time.Minute), now.Add(time.Minute), 0)
if err != nil {
t.Fatal(err)
diff --git a/internal/monitoring/monitor_agents.go b/internal/monitoring/monitor_agents.go
index 241750c3d5..589516c78f 100644
--- a/internal/monitoring/monitor_agents.go
+++ b/internal/monitoring/monitor_agents.go
@@ -4082,7 +4082,7 @@ func (m *Monitor) writeHostSMARTMetrics(host models.Host, now time.Time) {
}
for _, disk := range host.Sensors.SMART {
- resourceID := unifiedresources.HostSMARTDiskSourceID(host, disk)
+ resourceID := unifiedresources.HostSMARTDiskMetricID(host, disk)
if resourceID == "" {
continue
}
@@ -4234,7 +4234,7 @@ func hostDiskIOMetricResourceID(host models.Host, io models.DiskIO, proxmoxDisks
continue
}
if strings.EqualFold(normalizeHostDiskDevice(disk.Device), device) {
- candidate := unifiedresources.HostSMARTDiskSourceID(host, disk)
+ candidate := unifiedresources.HostSMARTDiskMetricID(host, disk)
if smartMetricID != "" && smartMetricID != candidate {
// Multiple controller members share this kernel block path.
// The counter belongs to the aggregate device, not any member.
diff --git a/internal/unifiedresources/physical_disk_ids.go b/internal/unifiedresources/physical_disk_ids.go
index 45ef9ce537..a47ee8caa5 100644
--- a/internal/unifiedresources/physical_disk_ids.go
+++ b/internal/unifiedresources/physical_disk_ids.go
@@ -21,7 +21,17 @@ func PreferredPhysicalDiskMetricID(serial, wwn, fallback string) string {
return strings.TrimSpace(fallback)
}
+// HostSMARTDiskSourceID returns the registry source ID of a disk a host agent
+// reports through SMART.
func HostSMARTDiskSourceID(host models.Host, disk models.HostDiskSMART) string {
+ return HostSMARTDiskMetricID(host, disk)
+}
+
+// HostSMARTDiskMetricID returns the history key a host agent's SMART and disk
+// I/O metrics are written under. Like every physical-disk source, it prefers
+// the drive's serial or WWN, so a disk keeps one history across sources and
+// hosts; see PreferredPhysicalDiskMetricID.
+func HostSMARTDiskMetricID(host models.Host, disk models.HostDiskSMART) string {
device := normalizePhysicalDiskDeviceToken(disk.Device)
return diskinventory.PreferredID(
disk.Serial,