From c3626cc3629eb8470e1a1dddd137446871051297 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Sun, 23 Nov 2025 12:58:16 +0100 Subject: [PATCH] Fix unified pool visualization filesystem children display issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix extract_pool_name() to handle filesystem metrics (_fs_) correctly - Prevent individual filesystem pools (nvme0n1_fs_boot, nvme0n1_fs_root) from being created - Fix incorrect mount point names (was showing /root/mount instead of /) - Only create filesystem entries when receiving mount_point metrics - Add available_gb field to FileSystem struct for proper available space handling - Ensure filesystem children show correct usage data instead of —% —GB/—GB --- Cargo.lock | 4 ++-- agent/Cargo.toml | 2 +- dashboard/Cargo.toml | 2 +- dashboard/src/ui/widgets/system.rs | 34 ++++++++++++++++++++++++------ shared/Cargo.toml | 2 +- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2bb1378..79cd2ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.102" +version = "0.1.103" dependencies = [ "anyhow", "chrono", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.102" +version = "0.1.103" dependencies = [ "anyhow", "async-trait", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 289470f..2da9dc9 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.103" +version = "0.1.104" edition = "2021" [dependencies] diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index c8fd45b..7bd153a 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.103" +version = "0.1.104" edition = "2021" [dependencies] diff --git a/dashboard/src/ui/widgets/system.rs b/dashboard/src/ui/widgets/system.rs index 921ef18..25aff45 100644 --- a/dashboard/src/ui/widgets/system.rs +++ b/dashboard/src/ui/widgets/system.rs @@ -70,6 +70,7 @@ struct FileSystem { usage_percent: Option, used_gb: Option, total_gb: Option, + available_gb: Option, status: Status, } @@ -255,15 +256,21 @@ impl SystemWidget { }); if !fs_exists { - // Extract actual mount point from mount_point metric if available - let mount_point = if metric_type == "mount_point" { - if let MetricValue::String(mount) = &metric.value { - mount.clone() + // Only create filesystem entry if we have the mount_point metric + // This ensures we get the correct mount point path + if metric_type != "mount_point" { + continue; // Skip non-mount_point metrics if filesystem doesn't exist yet + } + + let mount_point = if let MetricValue::String(mount) = &metric.value { + mount.clone() + } else { + // Fallback: handle special cases + if fs_name == "root" { + "/".to_string() } else { format!("/{}", fs_name.replace('_', "/")) } - } else { - format!("/{}", fs_name.replace('_', "/")) }; pool.filesystems.push(FileSystem { @@ -271,6 +278,7 @@ impl SystemWidget { usage_percent: None, used_gb: None, total_gb: None, + available_gb: None, status: Status::Unknown, }); } @@ -301,6 +309,11 @@ impl SystemWidget { filesystem.total_gb = Some(total); } } + "available_gb" => { + if let MetricValue::Float(available) = metric.value { + filesystem.available_gb = Some(available); + } + } "mount_point" => { if let MetricValue::String(mount) = &metric.value { filesystem.mount_point = mount.clone(); @@ -336,10 +349,17 @@ impl SystemWidget { return Some(metric_name[5..drive_start].to_string()); // Skip "disk_" } } + // Handle filesystem metrics: disk_{pool}_fs_{filesystem}_{metric} + else if metric_name.contains("_fs_") { + if let Some(fs_pos) = metric_name.find("_fs_") { + return Some(metric_name[5..fs_pos].to_string()); // Skip "disk_", extract pool name before "_fs_" + } + } // For pool-level metrics (usage_percent, used_gb, total_gb), take everything before the metric suffix else if let Some(suffix_pos) = metric_name.rfind("_usage_percent") .or_else(|| metric_name.rfind("_used_gb")) - .or_else(|| metric_name.rfind("_total_gb")) { + .or_else(|| metric_name.rfind("_total_gb")) + .or_else(|| metric_name.rfind("_available_gb")) { return Some(metric_name[5..suffix_pos].to_string()); // Skip "disk_" } // Fallback to old behavior for unknown patterns diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 980ead0..7045c9b 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.103" +version = "0.1.104" edition = "2021" [dependencies]