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.

Parse OPNsense 'Current Drive Temperature' SMART output

rcourtman9fe769ecdb6f
diff --git a/internal/hostagent/smartctl.go b/internal/hostagent/smartctl.go
index e030674aa1..1be2336cfa 100644
--- a/internal/hostagent/smartctl.go
+++ b/internal/hostagent/smartctl.go
@@ -201,7 +201,7 @@ type smartTextFallback struct {
var (
smartTextTempAttributeRE = regexp.MustCompile(`^\s*(190|194)\s+\S+.*-\s+(\d{1,3})\b`)
- smartTextCurrentTempRE = regexp.MustCompile(`(?i)^current temperature:\s*(\d{1,3})\b`)
+ smartTextCurrentTempRE = regexp.MustCompile(`(?i)^current(?: drive)? temperature:\s*(\d{1,3})\b`)
smartTextTemperatureRE = regexp.MustCompile(`(?i)^temperature:\s*(\d{1,3})\b`)
)
diff --git a/internal/hostagent/smartctl_test.go b/internal/hostagent/smartctl_test.go
index fd22c1f343..a1b19cd110 100644
--- a/internal/hostagent/smartctl_test.go
+++ b/internal/hostagent/smartctl_test.go
@@ -505,6 +505,29 @@ Current Temperature: 39 C
}
}
+func TestParseSMARTOutputParsesCurrentDriveTemperature(t *testing.T) {
+ // OPNsense/pfSense smartctl emits "Current Drive Temperature" rather than
+ // "Current Temperature"; both must parse.
+ output := []byte(`
+=== START OF INFORMATION SECTION ===
+Device Model: WDC WD40EFRX
+Serial Number: WD-456
+SMART overall-health self-assessment test result: PASSED
+Current Drive Temperature: 41 C
+`)
+
+ result, err := parseSMARTOutput(output, smartctlTarget{Path: "/dev/ada0"})
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+ if result == nil {
+ t.Fatal("expected result")
+ }
+ if result.Temperature != 41 {
+ t.Fatalf("expected 'Current Drive Temperature' to parse as 41, got %#v", result)
+ }
+}
+
func TestMatchesDeviceExclude(t *testing.T) {
tests := []struct {
name string