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
docs(alerts): govern SMART counter growth
pulse-triage[bot]1dc5ee49429c
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.mdindex c6f1bccae2..6315916628 100644--- a/docs/release-control/v6/internal/subsystems/alerts.md+++ b/docs/release-control/v6/internal/subsystems/alerts.md@@ -100,6 +100,24 @@ own inline boundary. A wearout arm keyed on `> 0` silently exempts the singleworst reading a disk can publish, which let a spent SSD read critical on thePhysical Disks surface while raising no alert at all.+Host SMART counter growth is an event boundary rather than a warning on every+historical non-zero value. For an agent-only disk, the first reported UDMA CRC+error count establishes an in-memory baseline and raises no alert. A later+increase contributes `crc_errors_increased` as a warning reason to that disk's+canonical `disk-health` assessment; the next stable sample resolves the active+growth event while normal alert and notification history retain it. A lower+counter, including a reset or disk replacement, establishes a new baseline and+must not alert. Missing or negative evidence cannot create a baseline or prove+growth. Baselines are bounded tracking state, are discarded by a full alert+state reset, and expire after the standard stale-tracking window. Linked+Proxmox host agents continue to defer SMART risk alert ownership to the+provider-backed disk surface rather than creating a duplicate host alert.+`TestCheckHostAlertsWhenSMARTCRCCountIncreases`,+`TestCheckHostSMARTCRCCounterResetEstablishesNewBaseline`, and+`TestCleanupRemovesOnlyStaleSMARTCounterSnapshots` in+`internal/alerts/alerts_test.go` pin the baseline, growth, reset, recovery, and+retention boundaries.+Threshold sections are keyed by override identity, not by resource type. TheVirtualization Hosts section reads and writes overrides on the bare resource id,while the Machines section resolves through the agent-derived identitydiff --git a/internal/alerts/alerts_test.go b/internal/alerts/alerts_test.goindex a2b809b218..c2e3d659a2 100644--- a/internal/alerts/alerts_test.go+++ b/internal/alerts/alerts_test.go@@ -20688,3 +20688,124 @@ func TestSystemAlertIDRejectsAnEmptyType(t *testing.T) {t.Error("expected a blank system alert type to raise nothing")}}++func TestCheckHostAlertsWhenSMARTCRCCountIncreases(t *testing.T) {+ m := newTestManager(t)+ m.ClearActiveAlerts()++ crcErrors := int64(7)+ host := models.Host{+ ID: "crc-host",+ Hostname: "crc-host",+ Sensors: models.HostSensorSummary{+ SMART: []models.HostDiskSMART{{+ Device: "/dev/sda",+ Health: "PASSED",+ Attributes: &models.SMARTAttributes{+ UDMACRCErrors: &crcErrors,+ },+ }},+ },+ }++ alertKey := buildCanonicalStateID("agent:crc-host/disk:sda", "agent:crc-host/disk:sda-disk-health")+ m.CheckHost(host)++ m.mu.RLock()+ _, exists := testLookupActiveAlert(t, m, alertKey)+ m.mu.RUnlock()+ if exists {+ t.Fatal("historical CRC errors must not alert on the first observation")+ }++ crcErrors = 8+ m.CheckHost(host)++ m.mu.RLock()+ alert := testRequireActiveAlert(t, m, alertKey)+ m.mu.RUnlock()+ if alert.Level != AlertLevelWarning {+ t.Fatalf("Level = %q, want %q", alert.Level, AlertLevelWarning)+ }+ if codes, ok := alert.Metadata["riskCodes"].([]string); !ok || !reflect.DeepEqual(codes, []string{"crc_errors_increased"}) {+ t.Fatalf("riskCodes = %#v, want crc_errors_increased", alert.Metadata["riskCodes"])+ }+ summaries, ok := alert.Metadata["riskSummaries"].([]string)+ if !ok || len(summaries) != 1 || !strings.Contains(summaries[0], "increased from 7 to 8") {+ t.Fatalf("riskSummaries = %#v, want counter delta", alert.Metadata["riskSummaries"])+ }++ // Growth is an event, not a warning on the historical non-zero value. Once+ // the next sample is stable, the active alert resolves while history keeps it.+ m.CheckHost(host)+ m.mu.RLock()+ _, exists = testLookupActiveAlert(t, m, alertKey)+ m.mu.RUnlock()+ if exists {+ t.Fatal("stable CRC counter should resolve the growth alert")+ }+}++func TestCheckHostSMARTCRCCounterResetEstablishesNewBaseline(t *testing.T) {+ m := newTestManager(t)+ m.ClearActiveAlerts()++ crcErrors := int64(10)+ host := models.Host{+ ID: "reset-host",+ Sensors: models.HostSensorSummary{SMART: []models.HostDiskSMART{{+ Device: "/dev/sdb",+ Attributes: &models.SMARTAttributes{UDMACRCErrors: &crcErrors},+ }}},+ }++ alertKey := buildCanonicalStateID("agent:reset-host/disk:sdb", "agent:reset-host/disk:sdb-disk-health")+ m.CheckHost(host)+ crcErrors = 1+ m.CheckHost(host)++ m.mu.RLock()+ _, exists := testLookupActiveAlert(t, m, alertKey)+ m.mu.RUnlock()+ if exists {+ t.Fatal("counter reset must not be treated as growth")+ }++ crcErrors = 2+ m.CheckHost(host)+ m.mu.RLock()+ alert := testRequireActiveAlert(t, m, alertKey)+ m.mu.RUnlock()+ if alert.Level != AlertLevelWarning {+ t.Fatalf("Level = %q, want %q", alert.Level, AlertLevelWarning)+ }+}++func TestCleanupRemovesOnlyStaleSMARTCounterSnapshots(t *testing.T) {+ m := newTestManager(t)+ now := time.Now()++ m.mu.Lock()+ m.smartCounterSnapshots["agent:old/disk:sda"] = smartCounterSnapshot{+ UDMACRCErrors: 3,+ LastObserved: now.Add(-25 * time.Hour),+ }+ m.smartCounterSnapshots["agent:current/disk:sdb"] = smartCounterSnapshot{+ UDMACRCErrors: 4,+ LastObserved: now.Add(-time.Hour),+ }+ m.mu.Unlock()++ m.Cleanup(time.Hour)++ m.mu.RLock()+ _, oldExists := m.smartCounterSnapshots["agent:old/disk:sda"]+ _, currentExists := m.smartCounterSnapshots["agent:current/disk:sdb"]+ m.mu.RUnlock()+ if oldExists {+ t.Fatal("stale SMART counter snapshot was not removed")+ }+ if !currentExists {+ t.Fatal("current SMART counter snapshot was removed")+ }+}diff --git a/internal/alerts/host_smart_growth_test.go b/internal/alerts/host_smart_growth_test.godeleted file mode 100644index d54a19ab6b..0000000000--- a/internal/alerts/host_smart_growth_test.go+++ /dev/null@@ -1,132 +0,0 @@-package alerts--import (- "slices"- "strings"- "testing"- "time"-- "github.com/rcourtman/pulse-go-rewrite/internal/models"-)--func TestCheckHostAlertsWhenSMARTCRCCountIncreases(t *testing.T) {- m := newTestManager(t)- m.ClearActiveAlerts()-- crcErrors := int64(7)- host := models.Host{- ID: "crc-host",- Hostname: "crc-host",- Sensors: models.HostSensorSummary{- SMART: []models.HostDiskSMART{{- Device: "/dev/sda",- Health: "PASSED",- Attributes: &models.SMARTAttributes{- UDMACRCErrors: &crcErrors,- },- }},- },- }-- alertKey := buildCanonicalStateID("agent:crc-host/disk:sda", "agent:crc-host/disk:sda-disk-health")- m.CheckHost(host)-- m.mu.RLock()- _, exists := testLookupActiveAlert(t, m, alertKey)- m.mu.RUnlock()- if exists {- t.Fatal("historical CRC errors must not alert on the first observation")- }-- crcErrors = 8- m.CheckHost(host)-- m.mu.RLock()- alert := testRequireActiveAlert(t, m, alertKey)- m.mu.RUnlock()- if alert.Level != AlertLevelWarning {- t.Fatalf("Level = %q, want %q", alert.Level, AlertLevelWarning)- }- codes, ok := alert.Metadata["riskCodes"].([]string)- if !ok || !slices.Contains(codes, "crc_errors_increased") {- t.Fatalf("riskCodes = %#v, want crc_errors_increased", alert.Metadata["riskCodes"])- }- summaries, ok := alert.Metadata["riskSummaries"].([]string)- if !ok || len(summaries) != 1 || !strings.Contains(summaries[0], "increased from 7 to 8") {- t.Fatalf("riskSummaries = %#v, want counter delta", alert.Metadata["riskSummaries"])- }-- // Growth is an event, not a warning on the historical non-zero value. Once- // the next sample is stable, the active alert resolves while history keeps it.- m.CheckHost(host)- m.mu.RLock()- _, exists = testLookupActiveAlert(t, m, alertKey)- m.mu.RUnlock()- if exists {- t.Fatal("stable CRC counter should resolve the growth alert")- }-}--func TestCheckHostSMARTCRCCounterResetEstablishesNewBaseline(t *testing.T) {- m := newTestManager(t)- m.ClearActiveAlerts()-- crcErrors := int64(10)- host := models.Host{- ID: "reset-host",- Sensors: models.HostSensorSummary{SMART: []models.HostDiskSMART{{- Device: "/dev/sdb",- Attributes: &models.SMARTAttributes{UDMACRCErrors: &crcErrors},- }}},- }-- alertKey := buildCanonicalStateID("agent:reset-host/disk:sdb", "agent:reset-host/disk:sdb-disk-health")- m.CheckHost(host)- crcErrors = 1- m.CheckHost(host)-- m.mu.RLock()- _, exists := testLookupActiveAlert(t, m, alertKey)- m.mu.RUnlock()- if exists {- t.Fatal("counter reset must not be treated as growth")- }-- crcErrors = 2- m.CheckHost(host)- m.mu.RLock()- alert := testRequireActiveAlert(t, m, alertKey)- m.mu.RUnlock()- if alert.Level != AlertLevelWarning {- t.Fatalf("Level = %q, want %q", alert.Level, AlertLevelWarning)- }-}--func TestCleanupRemovesOnlyStaleSMARTCounterSnapshots(t *testing.T) {- m := newTestManager(t)- now := time.Now()-- m.mu.Lock()- m.smartCounterSnapshots["agent:old/disk:sda"] = smartCounterSnapshot{- UDMACRCErrors: 3,- LastObserved: now.Add(-25 * time.Hour),- }- m.smartCounterSnapshots["agent:current/disk:sdb"] = smartCounterSnapshot{- UDMACRCErrors: 4,- LastObserved: now.Add(-time.Hour),- }- m.mu.Unlock()-- m.Cleanup(time.Hour)-- m.mu.RLock()- _, oldExists := m.smartCounterSnapshots["agent:old/disk:sda"]- _, currentExists := m.smartCounterSnapshots["agent:current/disk:sdb"]- m.mu.RUnlock()- if oldExists {- t.Fatal("stale SMART counter snapshot was not removed")- }- if !currentExists {- t.Fatal("current SMART counter snapshot was removed")- }-}