From 0b1d8c0a7378211d8112aa264c257598d0412947 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Sun, 30 Nov 2025 00:35:19 +0100 Subject: [PATCH] Fix Data_3 showing as unknown by handling smartctl warning exit codes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: sda's temperature exceeded threshold in the past, causing smartctl to return exit code 32 (warning: "Attributes have been <= threshold in the past"). The agent checked output.status.success() and rejected the entire output as failed, even though the data (serial, temperature, health) was perfectly valid. Smartctl exit codes are bit flags for informational warnings: - Exit 0: No warnings - Exit 32 (bit 5): Attributes were at/below threshold in past - Exit 64 (bit 6): Error log has entries - etc. The output data is valid regardless of these warning flags. Solution: Parse output as long as it's not empty, ignore exit code. Only return UNKNOWN if output is actually empty (command truly failed). Result: Data_3 will now show "ZDZ4VE0B T: 31°C" instead of "? Data_3: sda" Bump version to v0.1.225 --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- agent/src/collectors/disk.rs | 8 +++++--- dashboard/Cargo.toml | 2 +- shared/Cargo.toml | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d58757..0efcc65 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.223" +version = "0.1.224" dependencies = [ "anyhow", "chrono", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.223" +version = "0.1.224" dependencies = [ "anyhow", "async-trait", @@ -325,7 +325,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.223" +version = "0.1.224" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 80f2ac0..515fce3 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.224" +version = "0.1.225" edition = "2021" [dependencies] diff --git a/agent/src/collectors/disk.rs b/agent/src/collectors/disk.rs index 57049e3..f377c0d 100644 --- a/agent/src/collectors/disk.rs +++ b/agent/src/collectors/disk.rs @@ -451,8 +451,10 @@ impl DiskCollector { let output_str = String::from_utf8_lossy(&output.stdout); - if !output.status.success() { - // Return unknown data rather than failing completely + // Note: smartctl returns non-zero exit codes for warnings (like exit code 32 + // for "temperature was high in the past"), but the output data is still valid. + // Only check if we got any output at all, don't reject based on exit code. + if output_str.is_empty() { return Ok(SmartData { health: "UNKNOWN".to_string(), serial_number: None, @@ -460,7 +462,7 @@ impl DiskCollector { wear_percent: None, }); } - + let mut health = "UNKNOWN".to_string(); let mut serial_number = None; let mut temperature = None; diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 6812624..baf6080 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.224" +version = "0.1.225" edition = "2021" [dependencies] diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 2d6c41b..fa92dd2 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.224" +version = "0.1.225" edition = "2021" [dependencies]