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
Teach the host agent ZFS matcher nvme-eui and namespace-suffixed references
rcourtman2991ed9a95e2
diff --git a/internal/hostagent/zfs.go b/internal/hostagent/zfs.goindex a9437dc39f..d7dd2e638e 100644--- a/internal/hostagent/zfs.go+++ b/internal/hostagent/zfs.go@@ -184,6 +184,7 @@ func poolForSMARTEntry(pools map[string]string, entry agentshost.DiskSMART) stri}if entry.WWN != "" {wwn := strings.TrimPrefix(strings.ToLower(strings.TrimSpace(entry.WWN)), "0x")+ wwn = strings.TrimPrefix(wwn, "eui.")if pool := try(wwn); pool != "" {return pool}@@ -283,6 +284,14 @@ func zfsSerialFromByID(name string) string {if idx := strings.LastIndex(n, "-part"); idx > 0 {n = n[:idx]}+ // nvme-eui.<hex> references carry the device's WWN/EUI rather than a+ // serial; smartctl reports the same value as "eui.<hex>" or "0x<hex>".+ if strings.HasPrefix(n, "nvme-eui.") {+ return strings.TrimPrefix(n, "nvme-eui.")+ }+ // systemd's nvme by-id links can carry a trailing _<n> namespace suffix+ // (nvme-MODEL_SERIAL_1); the serial is the token before it (#1540).+ n = stripZFSNVMeNamespaceSuffix(n)if idx := strings.LastIndex(n, "_"); idx > 0 {return n[idx+1:]}@@ -295,6 +304,28 @@ func zfsSerialFromByID(name string) string {return ""}+// stripZFSNVMeNamespaceSuffix removes the trailing _<n> namespace token+// systemd appends to nvme by-id link names (nvme-MODEL_SERIAL_1). Only short+// all-digit tokens are stripped, and only when another underscore token+// remains, so a genuine serial is never truncated.+func stripZFSNVMeNamespaceSuffix(name string) string {+ if !strings.HasPrefix(name, "nvme-") {+ return name+ }+ idx := strings.LastIndex(name, "_")+ if idx <= 0 {+ return name+ }+ suffix := name[idx+1:]+ if len(suffix) == 0 || len(suffix) > 3 || !allZFSDigits(suffix) {+ return name+ }+ if !strings.Contains(name[:idx], "_") {+ return name+ }+ return name[:idx]+}+func allZFSDigits(s string) bool {for i := 0; i < len(s); i++ {if !isZFSDigit(s[i]) {diff --git a/internal/hostagent/zfs_test.go b/internal/hostagent/zfs_test.goindex 5cad6d816f..8f00bb7930 100644--- a/internal/hostagent/zfs_test.go+++ b/internal/hostagent/zfs_test.go@@ -2,6 +2,8 @@ package hostagentimport ("testing"++ agentshost "github.com/rcourtman/pulse-go-rewrite/pkg/agents/host")func TestParseZpoolStatusMembers(t *testing.T) {@@ -84,6 +86,56 @@ func TestNormalizeZFSMemberKeysCoverage(t *testing.T) {}}+func TestNormalizeZFSMemberKeysNVMeEUI(t *testing.T) {+ got := normalizeZFSMemberKeys("/dev/disk/by-id/nvme-eui.0025385b91501234-part3")+ expected := []string{+ "/dev/disk/by-id/nvme-eui.0025385b91501234-part3",+ "nvme-eui.0025385b91501234-part3",+ "nvme-eui.0025385b91501234",+ "0025385b91501234",+ }+ gotSet := map[string]struct{}{}+ for _, k := range got {+ gotSet[k] = struct{}{}+ }+ for _, want := range expected {+ if _, ok := gotSet[want]; !ok {+ t.Fatalf("missing key %q in %v", want, got)+ }+ }+}++func TestNormalizeZFSMemberKeysNVMeNamespaceSuffix(t *testing.T) {+ // systemd nvme by-id links may carry a trailing _<n> namespace suffix; the+ // serial key must be the real serial, not the namespace digit (#1540).+ got := normalizeZFSMemberKeys(+ "/dev/disk/by-id/nvme-Samsung_SSD_990_PRO_4TB_S7DPNF0Y316714T_1-part1",+ )+ gotSet := map[string]struct{}{}+ for _, k := range got {+ gotSet[k] = struct{}{}+ }+ if _, ok := gotSet["s7dpnf0y316714t"]; !ok {+ t.Fatalf("missing serial key in %v", got)+ }+}++func TestPoolForSMARTEntryMatchesEUIWWN(t *testing.T) {+ pools := map[string]string{}+ for _, key := range normalizeZFSMemberKeys("/dev/disk/by-id/nvme-eui.0025385b91501234-part3") {+ pools[key] = "local-zfs"+ }+ cases := []agentshost.DiskSMART{+ {Device: "/dev/nvme1n1", WWN: "eui.0025385B91501234"},+ {Device: "/dev/nvme1n1", WWN: "0x0025385b91501234"},+ }+ for _, entry := range cases {+ if got := poolForSMARTEntry(pools, entry); got != "local-zfs" {+ t.Fatalf("poolForSMARTEntry(WWN=%q) = %q, want local-zfs", entry.WWN, got)+ }+ }+}+func TestStripZFSPartitionSuffix(t *testing.T) {cases := map[string]string{"sda": "sda",