From 86501fd486761b11921a5a598626dca3af7f9a52 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Sun, 23 Nov 2025 18:13:35 +0100 Subject: [PATCH] Fix display format to match CLAUDE.md specification - Use actual device names (sdb, sdc) instead of data_0, parity_0 - Fix physical drive naming to show device names instead of mount points - Update pool name extraction to handle new device-based naming - Ensure Drive: line shows temperature and wear data for physical drives --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- agent/src/collectors/disk.rs | 8 +++---- dashboard/Cargo.toml | 2 +- dashboard/src/ui/widgets/system.rs | 34 +++++++----------------------- shared/Cargo.toml | 2 +- 6 files changed, 18 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 015713b..de65356 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.124" +version = "0.1.125" dependencies = [ "anyhow", "chrono", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.124" +version = "0.1.125" dependencies = [ "anyhow", "async-trait", @@ -324,7 +324,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.124" +version = "0.1.125" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 473a74c..7223d30 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.124" +version = "0.1.125" edition = "2021" [dependencies] diff --git a/agent/src/collectors/disk.rs b/agent/src/collectors/disk.rs index 6f3ee0f..2ea18a5 100644 --- a/agent/src/collectors/disk.rs +++ b/agent/src/collectors/disk.rs @@ -905,12 +905,12 @@ impl DiskCollector { }); // Individual drive metrics - for (i, drive) in pool.data_drives.iter().enumerate() { - self.generate_pool_drive_metrics(metrics, &pool_name, &format!("data_{}", i), drive, timestamp, status_tracker); + for drive in &pool.data_drives { + self.generate_pool_drive_metrics(metrics, &pool_name, &drive.device, drive, timestamp, status_tracker); } - for (i, drive) in pool.parity_drives.iter().enumerate() { - self.generate_pool_drive_metrics(metrics, &pool_name, &format!("parity_{}", i), drive, timestamp, status_tracker); + for drive in &pool.parity_drives { + self.generate_pool_drive_metrics(metrics, &pool_name, &drive.device, drive, timestamp, status_tracker); } } diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 64c3717..f8f4642 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.124" +version = "0.1.125" edition = "2021" [dependencies] diff --git a/dashboard/src/ui/widgets/system.rs b/dashboard/src/ui/widgets/system.rs index 0c6be93..35f23fe 100644 --- a/dashboard/src/ui/widgets/system.rs +++ b/dashboard/src/ui/widgets/system.rs @@ -153,7 +153,9 @@ impl SystemWidget { "steampool" => "/mnt/steampool".to_string(), "steampool_1" => "/steampool_1".to_string(), "steampool_2" => "/steampool_2".to_string(), - _ => format!("/{}", pool_name), // Default fallback + // For device names (nvme0n1, sda, etc.), use the device name directly + name if name.starts_with("nvme") || name.starts_with("sd") || name.starts_with("hd") => name.to_string(), + _ => format!("/{}", pool_name), // Default fallback for mount-based pools } } @@ -365,26 +367,13 @@ impl SystemWidget { .or_else(|| metric_name.rfind("_pool_health")) { return Some(metric_name[5..suffix_pos].to_string()); // Skip "disk_" } - // Handle drive-specific metrics: disk_{pool}_{drive_role}_{metric} (for mergerfs) or disk_{pool}_{drive}_{metric} (for physical drives) + // Handle drive-specific metrics: disk_{pool}_{drive}_{metric} else if let Some(suffix_pos) = metric_name.rfind("_temperature") .or_else(|| metric_name.rfind("_wear_percent")) .or_else(|| metric_name.rfind("_health")) { - // For mergerfs pools, metrics look like: disk_srv_media_data_0_temperature or disk_srv_media_parity_0_temperature - // We need to extract just "srv_media" as the pool name + // For both mergerfs and physical drives: disk_{pool_name}_{drive_name}_{metric} + // Extract pool name by finding the second-to-last underscore let before_suffix = &metric_name[..suffix_pos]; - - // Check if this looks like a mergerfs drive metric (contains data_ or parity_) - if before_suffix.contains("_data_") { - if let Some(data_pos) = before_suffix.find("_data_") { - return Some(metric_name[5..data_pos].to_string()); // Extract pool name before "_data_" - } - } else if before_suffix.contains("_parity_") { - if let Some(parity_pos) = before_suffix.find("_parity_") { - return Some(metric_name[5..parity_pos].to_string()); // Extract pool name before "_parity_" - } - } - - // Fallback for physical drive metrics: find the second-to-last underscore if let Some(drive_start) = before_suffix.rfind('_') { if drive_start > 5 { return Some(metric_name[5..drive_start].to_string()); // Skip "disk_" @@ -429,7 +418,7 @@ impl SystemWidget { /// Extract drive name from disk metric name fn extract_drive_name(&self, metric_name: &str) -> Option { // Pattern: disk_{pool_name}_{drive_name}_{metric_type} - // For mergerfs: disk_{pool_name}_{data|parity}_{index}_{metric_type} + // Now using actual device names like: disk_srv_media_sdb_temperature // Since pool_name can contain underscores, work backwards from known metric suffixes if metric_name.starts_with("disk_") { if let Some(suffix_pos) = metric_name.rfind("_temperature") @@ -437,14 +426,7 @@ impl SystemWidget { .or_else(|| metric_name.rfind("_health")) { let before_suffix = &metric_name[..suffix_pos]; - // For mergerfs drive metrics: extract the role_index part (e.g., "data_0", "parity_1") - if before_suffix.contains("_data_") || before_suffix.contains("_parity_") { - if let Some(role_start) = before_suffix.rfind("_data_").or_else(|| before_suffix.rfind("_parity_")) { - return Some(before_suffix[role_start + 1..].to_string()); // e.g., "data_0" or "parity_1" - } - } - - // Fallback for physical drive metrics: get the last component + // Extract the last component as drive name (e.g., "sdb", "sdc", "nvme0n1") if let Some(drive_start) = before_suffix.rfind('_') { return Some(before_suffix[drive_start + 1..].to_string()); } diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 79c3af7..9454e2f 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.124" +version = "0.1.125" edition = "2021" [dependencies]