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.

Retain dismissed TrueNAS SMART failures

pulse-triage[bot]79206d340a65
diff --git a/docs/TRUENAS.md b/docs/TRUENAS.md
index 3ef2576424..7eb4400b38 100644
--- a/docs/TRUENAS.md
+++ b/docs/TRUENAS.md
@@ -31,7 +31,7 @@ On your TrueNAS system:
| Apps | TrueNAS Overview | Native app state, image/version, ports, volumes, networks, and runtime container details |
| ZFS Pools | Storage | Total/used/free capacity, pool status (ONLINE/DEGRADED/FAULTED) |
| ZFS Datasets | Storage | Used/available space, mount status, read-only flag |
-| Physical Disks | Storage | Model, serial, size, transport type, rotational flag |
+| Physical Disks | Storage | Model, serial, size, transport type, rotational flag, temperature, and native SMART failure evidence |
| ZFS Snapshots | Recovery | Dataset, creation time, size, referenced data |
| Replication Tasks | Recovery | Source/target datasets, direction, last run status |
| TrueNAS Alerts | Alerts | Native TrueNAS alert messages and severity levels |
@@ -47,6 +47,12 @@ TrueNAS resources are mapped into the unified resource model:
- **ZFS snapshots and replication** → appear on the **Recovery** page as recovery points.
- **TrueNAS alerts** → surfaced on the **Alerts** page alongside Proxmox and other platform alerts.
+TrueNAS drive-health alerts that identify a specific disk remain disk-health
+evidence after they are dismissed in TrueNAS. Dismissal acknowledges the
+notification; Pulse continues to show the affected disk risk while TrueNAS
+continues to report the underlying SMART condition. Other dismissed TrueNAS
+alerts remain suppressed.
+
Resources from TrueNAS can be filtered using the **source** filter on any page.
## Multiple TrueNAS Systems
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index a6348e815c..28d01461e9 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -2620,7 +2620,15 @@ projection. When TrueNAS raises disk-local SMART alerts such as
`truenas_smart`, `internal/truenas/provider.go` must fold that incident truth
into the canonical physical-disk risk payload instead of leaving SMART failure
state trapped in incident/status-only decorations that storage consumers do
-not read.
+not read. Current TrueNAS drive-health releases expose failure counters through
+`alert.list` without exposing equivalent raw attributes through the supported
+disk API. Pulse must therefore retain a dismissed SMART alert only when its
+native arguments or serial resolve to exactly one currently inventoried disk:
+dismissal acknowledges notification state but does not erase monotonic hardware
+evidence. Other dismissed alerts, and dismissed SMART alerts with missing or
+ambiguous disk identity, remain suppressed. Native uncorrectable-error, failed
+self-test, and low-spare-block classes map to critical canonical disk risk even
+when TrueNAS labels the source alert as a warning.
The same boundary owns TrueNAS `smart_status` normalization. `internal/truenas/client.go`
must parse REST and RPC SMART status separately from native disk state, and
`internal/truenas/disk_health.go` plus `internal/truenas/provider.go` must map
diff --git a/internal/truenas/client.go b/internal/truenas/client.go
index 49aebada7a..1fa5a4a835 100644
--- a/internal/truenas/client.go
+++ b/internal/truenas/client.go
@@ -1220,17 +1220,21 @@ func (c *Client) getAlertsRPC(ctx context.Context) ([]Alert, error) {
if id == "" {
id = strings.TrimSpace(readStringAny(item, "klass"))
}
+ args := readMapAny(item, "args")
var datetime time.Time
if t := readTimeAny(item, "datetime", "last_occurrence", "lastOccurrence"); t != nil {
datetime = *t
}
alerts = append(alerts, Alert{
- ID: id,
- Level: strings.TrimSpace(readStringAny(item, "level")),
- Message: strings.TrimSpace(readStringAny(item, "formatted", "text", "message", "klass")),
- Source: strings.TrimSpace(readStringAny(item, "source", "node")),
- Dismissed: readBoolAny(item, "dismissed"),
- Datetime: datetime,
+ ID: id,
+ Level: strings.TrimSpace(readStringAny(item, "level")),
+ Message: strings.TrimSpace(readStringAny(item, "formatted", "text", "message", "klass")),
+ Source: strings.TrimSpace(readStringAny(item, "source", "node")),
+ Class: strings.TrimSpace(readStringAny(item, "klass", "class")),
+ DiskName: strings.TrimSpace(readStringAny(args, "name", "disk", "device")),
+ DiskSerial: strings.TrimSpace(readStringAny(args, "serial", "serial_number", "serialNumber")),
+ Dismissed: readBoolAny(item, "dismissed"),
+ Datetime: datetime,
})
}
return alerts, nil
@@ -1255,12 +1259,15 @@ func (c *Client) getAlertsREST(ctx context.Context) ([]Alert, error) {
}
alerts = append(alerts, Alert{
- ID: id,
- Level: strings.TrimSpace(item.Level),
- Message: strings.TrimSpace(item.Formatted),
- Source: strings.TrimSpace(item.Source),
- Dismissed: item.Dismissed,
- Datetime: time.UnixMilli(ms).UTC(),
+ ID: id,
+ Level: strings.TrimSpace(item.Level),
+ Message: strings.TrimSpace(item.Formatted),
+ Source: strings.TrimSpace(item.Source),
+ Class: strings.TrimSpace(item.Class),
+ DiskName: strings.TrimSpace(readStringAny(item.Args, "name", "disk", "device")),
+ DiskSerial: strings.TrimSpace(readStringAny(item.Args, "serial", "serial_number", "serialNumber")),
+ Dismissed: item.Dismissed,
+ Datetime: time.UnixMilli(ms).UTC(),
})
}
@@ -4489,6 +4496,8 @@ type alertResponse struct {
Level string `json:"level"`
Formatted string `json:"formatted"`
Source string `json:"source"`
+ Class string `json:"klass"`
+ Args map[string]any `json:"args"`
Dismissed bool `json:"dismissed"`
Datetime struct {
Date json.RawMessage `json:"$date"`
diff --git a/internal/truenas/client_test.go b/internal/truenas/client_test.go
index 5025682624..152a5e9bb4 100644
--- a/internal/truenas/client_test.go
+++ b/internal/truenas/client_test.go
@@ -297,7 +297,11 @@ func TestGetPoolsDatasetsAndAlertsUseNativeQueryShapes(t *testing.T) {
if !ok || len(params) != 0 {
t.Fatalf("expected alert.list to use no params, got %#v", request.Params)
}
- writeRPCResult(t, conn, request.ID, defaultRoutePayloadMaps(t, "/api/v2.0/alert/list"))
+ writeRPCResult(t, conn, request.ID, []map[string]any{{
+ "id": "a1", "level": "WARNING", "formatted": "Disk temp high", "source": "DiskService",
+ "klass": "DiskTemperatureAlert", "args": map[string]any{"name": "/dev/sda", "serial": "SER-A"},
+ "dismissed": false, "datetime": map[string]any{"$date": 1707400000000},
+ }})
default:
t.Fatalf("unexpected rpc method %q", request.Method)
}
@@ -325,11 +329,31 @@ func TestGetPoolsDatasetsAndAlertsUseNativeQueryShapes(t *testing.T) {
if err != nil {
t.Fatalf("GetAlerts() error = %v", err)
}
- if len(alerts) != 1 || alerts[0].ID != "a1" || alerts[0].Level != "WARNING" {
+ if len(alerts) != 1 || alerts[0].ID != "a1" || alerts[0].Level != "WARNING" ||
+ alerts[0].Class != "DiskTemperatureAlert" || alerts[0].DiskName != "/dev/sda" || alerts[0].DiskSerial != "SER-A" {
t.Fatalf("unexpected native alert mapping: %+v", alerts)
}
}
+func TestGetAlertsParsesLegacyDiskIdentityArguments(t *testing.T) {
+ responses := defaultAPIResponses()
+ responses["/api/v2.0/alert/list"] = apiResponse{
+ body: `[{"id":"smart-1","level":"WARNING","formatted":"53 uncorrectable errors reported for /dev/sda (SER-A).","source":"SMART","klass":"SMARTUncorrectedErrorsAlert","args":{"name":"/dev/sda","serial":"SER-A"},"dismissed":true,"datetime":{"$date":1707400000000}}]`,
+ }
+ server := newMockServer(t, responses, nil)
+ t.Cleanup(server.Close)
+
+ client := mustClientForServer(t, server.URL, ClientConfig{APIKey: "api-key"})
+ alerts, err := client.GetAlerts(context.Background())
+ if err != nil {
+ t.Fatalf("GetAlerts() error = %v", err)
+ }
+ if len(alerts) != 1 || alerts[0].Class != "SMARTUncorrectedErrorsAlert" ||
+ alerts[0].DiskName != "/dev/sda" || alerts[0].DiskSerial != "SER-A" || !alerts[0].Dismissed {
+ t.Fatalf("unexpected legacy SMART alert mapping: %+v", alerts)
+ }
+}
+
func TestGetServicesUsesNativeServiceQueryShape(t *testing.T) {
server := newMockServerWithRPC(t, map[string]apiResponse{
"/api/v2.0/service": {status: http.StatusInternalServerError, body: `{"error":"legacy service endpoint should not be used"}`},
diff --git a/internal/truenas/provider.go b/internal/truenas/provider.go
index 9d04ea2d11..104d7aef31 100644
--- a/internal/truenas/provider.go
+++ b/internal/truenas/provider.go
@@ -1181,24 +1181,45 @@ func buildIncidentAssignments(snapshot *FixtureSnapshot, observedAt time.Time) t
}
diskPools := make(map[string]string, len(snapshot.Disks))
+ knownDiskNames := make(map[string]string, len(snapshot.Disks))
+ diskNamesBySerial := make(map[string]string, len(snapshot.Disks))
for _, disk := range snapshot.Disks {
diskName := strings.TrimSpace(disk.Name)
poolName := strings.TrimSpace(disk.Pool)
- if diskName == "" || poolName == "" {
+ if diskName == "" {
continue
}
- diskPools[diskName] = poolName
+ knownDiskNames[strings.ToLower(diskName)] = diskName
+ if serial := strings.ToUpper(strings.TrimSpace(disk.Serial)); serial != "" {
+ if existing, exists := diskNamesBySerial[serial]; exists && existing != diskName {
+ // Duplicate serials are not sufficient identity. Leave the entry
+ // empty so a provider alert cannot be assigned to the wrong disk.
+ diskNamesBySerial[serial] = ""
+ } else {
+ diskNamesBySerial[serial] = diskName
+ }
+ }
+ if poolName != "" {
+ diskPools[diskName] = poolName
+ }
}
nativePoolSignals := make(map[string]map[string]struct{}, len(snapshot.Alerts))
for _, alert := range snapshot.Alerts {
- if alert.Dismissed {
- continue
- }
incident, ok := incidentFromAlert(alert)
if !ok {
continue
}
+ diskName := resolveAlertDiskName(alert, knownDiskNames, diskNamesBySerial)
+ // TrueNAS 25.10's drive-health manager exposes SMART counters through
+ // alert.list, while its supported disk API exposes no equivalent raw
+ // attribute feed. Acknowledging one of those disk-local SMART alerts
+ // changes notification state, not the underlying monotonic hardware
+ // evidence, so retain it until TrueNAS stops reporting the condition.
+ // All other dismissed alerts remain suppressed.
+ if alert.Dismissed && (incident.Code != "truenas_smart" || diskName == "") {
+ continue
+ }
assignments.System = append(assignments.System, incident)
if poolName := poolNameFromAlert(alert); poolName != "" {
@@ -1211,7 +1232,7 @@ func buildIncidentAssignments(snapshot *FixtureSnapshot, observedAt time.Time) t
}
}
- if diskName := diskNameFromAlert(alert); diskName != "" {
+ if diskName != "" {
assignments.Disks[diskName] = append(assignments.Disks[diskName], incident)
if poolName := diskPools[diskName]; poolName != "" {
assignments.Pools[poolName] = append(assignments.Pools[poolName], incident)
@@ -1268,6 +1289,15 @@ func incidentFromAlert(alert Alert) (unifiedresources.ResourceIncident, bool) {
if !ok {
return unifiedresources.ResourceIncident{}, false
}
+ // Pulse's provider-neutral storage policy treats uncorrectable media and
+ // failed self-tests as replacement-critical evidence even though TrueNAS
+ // currently labels two of those native alert classes WARNING.
+ switch strings.ToLower(strings.TrimSpace(alert.Class)) {
+ case "smartuncorrectederrors", "smartuncorrectederrorsalert",
+ "smartfailedselftest", "smartfailedselftestalert",
+ "smartspareblockcount", "smartspareblockcountalert":
+ severity = storagehealth.RiskCritical
+ }
return unifiedresources.ResourceIncident{
Provider: "truenas",
NativeID: strings.TrimSpace(alert.ID),
@@ -1534,11 +1564,13 @@ func severityFromAlertLevel(level string) (storagehealth.RiskLevel, bool) {
func incidentCodeFromAlert(alert Alert) string {
source := strings.ToLower(strings.TrimSpace(alert.Source))
+ class := strings.ToLower(strings.TrimSpace(alert.Class))
+ if source == "smart" || strings.HasPrefix(class, "smart") {
+ return "truenas_smart"
+ }
switch source {
case "volumestatus":
return "truenas_volume_status"
- case "smart":
- return "truenas_smart"
case "scrub":
return "truenas_scrub"
default:
@@ -1569,6 +1601,9 @@ func poolNameFromAlert(alert Alert) string {
}
func diskNameFromAlert(alert Alert) string {
+ if name := normalizeAlertDiskName(alert.DiskName); name != "" {
+ return name
+ }
message := strings.TrimSpace(alert.Message)
if message == "" {
return ""
@@ -1584,9 +1619,30 @@ func diskNameFromAlert(alert Alert) string {
}
end := strings.IndexAny(rest, " :.,")
if end < 0 {
- return strings.TrimSpace(rest)
+ return normalizeAlertDiskName(rest)
}
- return strings.TrimSpace(rest[:end])
+ return normalizeAlertDiskName(rest[:end])
+}
+
+func normalizeAlertDiskName(name string) string {
+ name = strings.TrimSpace(name)
+ name = strings.TrimPrefix(name, "/dev/")
+ if name == "" || strings.ContainsAny(name, `/\\`) || hasTraversalSegment(name) {
+ return ""
+ }
+ return name
+}
+
+func resolveAlertDiskName(alert Alert, knownDiskNames, diskNamesBySerial map[string]string) string {
+ if candidate := diskNameFromAlert(alert); candidate != "" {
+ if known := knownDiskNames[strings.ToLower(candidate)]; known != "" {
+ return known
+ }
+ }
+ if serial := strings.ToUpper(strings.TrimSpace(alert.DiskSerial)); serial != "" {
+ return diskNamesBySerial[serial]
+ }
+ return ""
}
func assessPool(pool Pool) storagehealth.Assessment {
diff --git a/internal/truenas/provider_test.go b/internal/truenas/provider_test.go
index 4f87800676..6644f373a1 100644
--- a/internal/truenas/provider_test.go
+++ b/internal/truenas/provider_test.go
@@ -4,6 +4,7 @@ import (
"context"
"errors"
"net/http"
+ "strings"
"testing"
"time"
@@ -1064,6 +1065,121 @@ func TestRecordsProjectExplicitFailedSMARTAsReplacementRisk(t *testing.T) {
}
}
+func TestRecordsRetainDismissedTrueNASSMARTFailureAsDiskRisk(t *testing.T) {
+ fixtures := FixtureSnapshot{
+ CollectedAt: time.Date(2026, 8, 28, 9, 30, 0, 0, time.UTC),
+ System: SystemInfo{
+ Hostname: "truenas-test",
+ Healthy: true,
+ },
+ Disks: []Disk{{
+ ID: "disk-sda",
+ Name: "sda",
+ Pool: "tank",
+ Status: "ONLINE",
+ Model: "Samsung SSD 870 EVO 4TB",
+ Serial: "SER-SDA",
+ SizeBytes: 4_000_787_030_016,
+ Transport: "sata",
+ Temperature: 36,
+ }},
+ Alerts: []Alert{
+ {
+ ID: "smart-uncorrected-sda",
+ Level: "WARNING",
+ Message: "53 uncorrectable errors reported for /dev/sda (SER-SDA).",
+ Source: "SMART",
+ Class: "SMARTUncorrectedErrorsAlert",
+ DiskName: "/dev/sda",
+ DiskSerial: "SER-SDA",
+ Dismissed: true,
+ Datetime: time.Date(2026, 8, 28, 8, 0, 0, 0, time.UTC),
+ },
+ {
+ ID: "dismissed-generic",
+ Level: "WARNING",
+ Message: "A dismissed non-SMART alert must remain suppressed.",
+ Source: "Replication",
+ DiskName: "/dev/sda",
+ Dismissed: true,
+ Datetime: time.Date(2026, 8, 28, 8, 0, 0, 0, time.UTC),
+ },
+ },
+ }
+
+ var diskRecord *unifiedresources.IngestRecord
+ records := FixtureRecords(fixtures)
+ for i := range records {
+ if records[i].Resource.Type == unifiedresources.ResourceTypePhysicalDisk && records[i].Resource.Name == "sda" {
+ diskRecord = &records[i]
+ break
+ }
+ }
+ if diskRecord == nil || diskRecord.Resource.PhysicalDisk == nil {
+ t.Fatal("expected canonical sda physical-disk record")
+ }
+ if len(diskRecord.Resource.Incidents) != 1 {
+ t.Fatalf("expected only dismissed SMART evidence to survive, got %+v", diskRecord.Resource.Incidents)
+ }
+ incident := diskRecord.Resource.Incidents[0]
+ if incident.Code != "truenas_smart" || incident.Severity != storagehealth.RiskCritical ||
+ !strings.Contains(incident.Summary, "53 uncorrectable errors") {
+ t.Fatalf("unexpected retained SMART incident: %+v", incident)
+ }
+ if risk := diskRecord.Resource.PhysicalDisk.Risk; risk == nil || risk.Level != storagehealth.RiskCritical ||
+ !containsRiskReason(risk.Reasons, "truenas_smart") {
+ t.Fatalf("expected retained SMART incident in critical physical-disk risk, got %+v", risk)
+ }
+}
+
+func TestDismissedTrueNASSMARTAlertRequiresExactDiskIdentity(t *testing.T) {
+ fixtures := FixtureSnapshot{
+ CollectedAt: time.Date(2026, 8, 28, 9, 30, 0, 0, time.UTC),
+ System: SystemInfo{Hostname: "truenas-test", Healthy: true},
+ Disks: []Disk{{
+ ID: "disk-sda", Name: "sda", Status: "ONLINE", Serial: "SER-SDA", Transport: "sata",
+ }},
+ Alerts: []Alert{{
+ ID: "smart-unknown", Level: "WARNING", Message: "uncorrectable errors reported",
+ Source: "SMART", Class: "SMARTUncorrectedErrorsAlert", DiskName: "/dev/sdz", Dismissed: true,
+ }},
+ }
+
+ records := FixtureRecords(fixtures)
+ for i := range records {
+ if records[i].Resource.Type != unifiedresources.ResourceTypePhysicalDisk {
+ continue
+ }
+ if len(records[i].Resource.Incidents) != 0 || records[i].Resource.PhysicalDisk.Risk != nil {
+ t.Fatalf("unresolved dismissed SMART alert must stay suppressed, got %+v", records[i].Resource)
+ }
+ }
+}
+
+func TestResolveAlertDiskNameUsesExactNativeIdentity(t *testing.T) {
+ knownNames := map[string]string{"sda": "sda"}
+ serials := map[string]string{"SER-SDA": "sda", "DUPLICATE": ""}
+ tests := []struct {
+ name string
+ alert Alert
+ want string
+ }{
+ {name: "native device argument", alert: Alert{DiskName: "/dev/sda"}, want: "sda"},
+ {name: "serial fallback", alert: Alert{DiskName: "/dev/unknown", DiskSerial: "ser-sda"}, want: "sda"},
+ {name: "unknown identity", alert: Alert{DiskName: "/dev/sdz", DiskSerial: "missing"}},
+ {name: "ambiguous serial", alert: Alert{DiskSerial: "duplicate"}},
+ {name: "unsafe device argument", alert: Alert{DiskName: "/dev/../sda", DiskSerial: "missing"}},
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if got := resolveAlertDiskName(tt.alert, knownNames, serials); got != tt.want {
+ t.Fatalf("resolveAlertDiskName() = %q, want %q", got, tt.want)
+ }
+ })
+ }
+}
+
func TestRecordsPreservePassedDegradedAndFailedDiskProjection(t *testing.T) {
tests := []struct {
name string
diff --git a/internal/truenas/types.go b/internal/truenas/types.go
index ea2e9dd990..f12d8567c9 100644
--- a/internal/truenas/types.go
+++ b/internal/truenas/types.go
@@ -200,12 +200,15 @@ type SystemMetricHistory struct {
// Alert mirrors a TrueNAS alert listing entry.
type Alert struct {
- ID string
- Level string
- Message string
- Source string
- Dismissed bool
- Datetime time.Time
+ ID string
+ Level string
+ Message string
+ Source string
+ Class string
+ DiskName string
+ DiskSerial string
+ Dismissed bool
+ Datetime time.Time
}
// Service mirrors the service.query system service inventory returned by