From ad298ac70c8184fbd90d6cbedd31302f755fabea Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Thu, 23 Oct 2025 19:06:52 +0200 Subject: [PATCH] Fix device detection, tree indentation, and hide Single storage type - Replace findmnt with lsblk for efficient device name detection - Fix tree indentation to align consistently with status icon text - Hide '(Single)' label for single disk storage pools - Device detection returns actual names (nvme0n1, sda) not UUID paths --- agent/src/collectors/disk.rs | 20 +++++++++++--------- dashboard/src/ui/widgets/system.rs | 15 ++++++++++----- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/agent/src/collectors/disk.rs b/agent/src/collectors/disk.rs index f226aea..fb87da0 100644 --- a/agent/src/collectors/disk.rs +++ b/agent/src/collectors/disk.rs @@ -262,10 +262,10 @@ impl DiskCollector { } } - /// Detect device backing a mount point using findmnt (static version for startup) + /// Detect device backing a mount point using lsblk (static version for startup) fn detect_device_for_mount_point_static(mount_point: &str) -> Result> { - let output = Command::new("findmnt") - .args(&["-n", "-o", "SOURCE", mount_point]) + let output = Command::new("lsblk") + .args(&["-n", "-o", "NAME,MOUNTPOINT"]) .output()?; if !output.status.success() { @@ -273,14 +273,16 @@ impl DiskCollector { } let output_str = String::from_utf8_lossy(&output.stdout); - let device_path = output_str.trim(); - // Extract device name from path (e.g., /dev/nvme0n1 -> nvme0n1) - if let Some(device_name) = device_path.strip_prefix("/dev/") { - Ok(vec![device_name.to_string()]) - } else { - Ok(Vec::new()) + for line in output_str.lines() { + let parts: Vec<&str> = line.split_whitespace().collect(); + if parts.len() >= 2 && parts[1] == mount_point { + let device_name = parts[0].trim(); + return Ok(vec![device_name.to_string()]); + } } + + Ok(Vec::new()) } /// Get directory size using du command (efficient for single directory) diff --git a/dashboard/src/ui/widgets/system.rs b/dashboard/src/ui/widgets/system.rs index f25857a..7e10f08 100644 --- a/dashboard/src/ui/widgets/system.rs +++ b/dashboard/src/ui/widgets/system.rs @@ -254,9 +254,14 @@ impl SystemWidget { _ => "—% —GB/—GB".to_string(), }; + let pool_label = if pool.pool_type.to_lowercase() == "single" { + format!("{}:", pool.mount_point) + } else { + format!("{} ({}):", pool.mount_point, pool.pool_type) + }; let pool_spans = StatusIcons::create_status_spans( pool.status.clone(), - &format!("{} ({}):", pool.mount_point, pool.pool_type) + &pool_label ); lines.push(Line::from(pool_spans)); @@ -280,7 +285,7 @@ impl SystemWidget { }; let mut drive_spans = vec![ - Span::raw(" "), + Span::raw(" "), Span::raw(tree_symbol), Span::raw(" "), ]; @@ -292,7 +297,7 @@ impl SystemWidget { if pool.usage_percent.is_some() { let tree_symbol = "└─"; let mut usage_spans = vec![ - Span::raw(" "), + Span::raw(" "), Span::raw(tree_symbol), Span::raw(" "), ]; @@ -429,7 +434,7 @@ impl Widget for SystemWidget { let freq_text = self.format_cpu_frequency(); lines.push(Line::from(vec![ - Span::raw("└─ "), + Span::raw(" └─ "), Span::styled(format!("Freq: {}", freq_text), Typography::secondary()) ])); @@ -443,7 +448,7 @@ impl Widget for SystemWidget { let tmp_text = self.format_tmp_usage(); let mut tmp_spans = vec![ - Span::raw(" └─ "), + Span::raw(" └─ "), ]; tmp_spans.extend(StatusIcons::create_status_spans( self.memory_status.clone(),