diff --git a/Cargo.lock b/Cargo.lock index 047b9b6..60788fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.119" +version = "0.1.120" dependencies = [ "anyhow", "chrono", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.119" +version = "0.1.120" dependencies = [ "anyhow", "async-trait", @@ -324,7 +324,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.119" +version = "0.1.120" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index b007cab..594a919 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.119" +version = "0.1.120" edition = "2021" [dependencies] diff --git a/agent/src/collectors/disk.rs b/agent/src/collectors/disk.rs index e49ffc2..1deaa70 100644 --- a/agent/src/collectors/disk.rs +++ b/agent/src/collectors/disk.rs @@ -203,17 +203,20 @@ impl DiskCollector { .unwrap_or((0, 0)); // Parse member paths - handle both full paths and numeric references - let member_paths: Vec = device_sources + let raw_paths: Vec = device_sources .split(':') .map(|s| s.trim().to_string()) .filter(|s| !s.is_empty()) .collect(); - // Skip this pool if we can't parse the member paths (e.g., numeric references like "1:2") - if member_paths.iter().any(|path| !path.starts_with('/')) { - debug!("Skipping mergerfs pool {} with unparseable member paths: {:?}", mount_point, member_paths); - continue; - } + // Convert numeric references to actual mount points if needed + let member_paths = if raw_paths.iter().any(|path| !path.starts_with('/')) { + // Handle numeric format like "1:2" by finding corresponding /mnt/disk* paths + self.resolve_numeric_mergerfs_paths(&raw_paths)? + } else { + // Already full paths + raw_paths + }; // Categorize as data vs parity drives let (data_drives, parity_drives) = match self.categorize_pool_drives(&member_paths) { @@ -298,6 +301,35 @@ impl DiskCollector { }) } + /// Resolve numeric mergerfs references like "1:2" to actual mount paths + fn resolve_numeric_mergerfs_paths(&self, numeric_refs: &[String]) -> Result> { + let mut resolved_paths = Vec::new(); + + // Get all mount points that look like /mnt/disk* or /mnt/parity* + let mount_devices = self.get_mount_devices()?; + let mut disk_mounts: Vec = mount_devices.keys() + .filter(|path| path.starts_with("/mnt/disk") || path.starts_with("/mnt/parity")) + .cloned() + .collect(); + disk_mounts.sort(); // Ensure consistent ordering + + for num_ref in numeric_refs { + if let Ok(index) = num_ref.parse::() { + // Convert 1-based index to 0-based + if index > 0 && index <= disk_mounts.len() { + resolved_paths.push(disk_mounts[index - 1].clone()); + } + } + } + + // Fallback: if we couldn't resolve, return the original paths + if resolved_paths.is_empty() { + resolved_paths = numeric_refs.to_vec(); + } + + Ok(resolved_paths) + } + /// Extract base device name from partition (e.g., "nvme0n1p2" -> "nvme0n1", "sda1" -> "sda") fn extract_base_device(&self, device_name: &str) -> String { // Handle NVMe devices (nvme0n1p1 -> nvme0n1) diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 482d896..4728093 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.119" +version = "0.1.120" edition = "2021" [dependencies] diff --git a/shared/Cargo.toml b/shared/Cargo.toml index ec9f4e6..618684a 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.119" +version = "0.1.120" edition = "2021" [dependencies]