From 1656f20e9639cbc61bdde6d9fd65dfe980c6c66b Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Thu, 11 Dec 2025 11:10:59 +0100 Subject: [PATCH] Fix NFS export parsing to handle both inline and continuation formats Support exportfs output where network info appears on same line as path (e.g. /srv/media/tv 192.168.0.0/16(...)) in addition to continuation line format. Ensures all NFS exports are detected correctly. --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- agent/src/collectors/systemd.rs | 29 +++++++++++++++++++++++++---- dashboard/Cargo.toml | 2 +- shared/Cargo.toml | 2 +- 5 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d795109..641ec72 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.273" +version = "0.1.274" dependencies = [ "anyhow", "chrono", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.273" +version = "0.1.274" dependencies = [ "anyhow", "async-trait", @@ -325,7 +325,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.273" +version = "0.1.274" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 6273d2d..c2dc32c 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.274" +version = "0.1.275" edition = "2021" [dependencies] diff --git a/agent/src/collectors/systemd.rs b/agent/src/collectors/systemd.rs index 943c7fe..9dcdcfc 100644 --- a/agent/src/collectors/systemd.rs +++ b/agent/src/collectors/systemd.rs @@ -1067,15 +1067,36 @@ impl SystemdCollector { } if trimmed.starts_with('/') { - // New export path line - current_path = trimmed.split_whitespace().next().map(|s| s.to_string()); + // Export path line - may have network on same line or continuation + let parts: Vec<&str> = trimmed.splitn(2, char::is_whitespace).collect(); + let path = parts[0].to_string(); + current_path = Some(path.clone()); + + // Check if network info is on the same line + if parts.len() > 1 { + let rest = parts[1].trim(); + if let Some(paren_pos) = rest.find('(') { + let network = rest[..paren_pos].trim(); + + if let Some(end_paren) = rest.find(')') { + let options = &rest[paren_pos+1..end_paren]; + let mode = if options.contains(",rw,") || options.ends_with(",rw") { + "rw" + } else { + "ro" + }; + + exports_map.entry(path) + .or_insert_with(Vec::new) + .push((network.to_string(), mode.to_string())); + } + } + } } else if let Some(ref path) = current_path { // Continuation line with network and options - // Format: "192.168.0.0/16(options...)" if let Some(paren_pos) = trimmed.find('(') { let network = trimmed[..paren_pos].trim(); - // Extract ro/rw from options if let Some(end_paren) = trimmed.find(')') { let options = &trimmed[paren_pos+1..end_paren]; let mode = if options.contains(",rw,") || options.ends_with(",rw") { diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 2ed0bc7..694e1ff 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.274" +version = "0.1.275" edition = "2021" [dependencies] diff --git a/shared/Cargo.toml b/shared/Cargo.toml index c9089b4..d6a498a 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.274" +version = "0.1.275" edition = "2021" [dependencies]