Simplify NFS export options display
All checks were successful
Build and Release / build-and-release (push) Successful in 1m14s

Filter NFS export options to show only key settings (rw/ro, sync/async)
instead of verbose option strings. Improves readability while maintaining
essential information about export configuration.
This commit is contained in:
Christoffer Martinsson 2025-12-11 10:26:27 +01:00
parent 7362464b46
commit a34b095857
5 changed files with 33 additions and 15 deletions

6
Cargo.lock generated
View File

@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
[[package]]
name = "cm-dashboard"
version = "0.1.271"
version = "0.1.272"
dependencies = [
"anyhow",
"chrono",
@ -301,7 +301,7 @@ dependencies = [
[[package]]
name = "cm-dashboard-agent"
version = "0.1.271"
version = "0.1.272"
dependencies = [
"anyhow",
"async-trait",
@ -325,7 +325,7 @@ dependencies = [
[[package]]
name = "cm-dashboard-shared"
version = "0.1.271"
version = "0.1.272"
dependencies = [
"chrono",
"serde",

View File

@ -1,6 +1,6 @@
[package]
name = "cm-dashboard-agent"
version = "0.1.272"
version = "0.1.273"
edition = "2021"
[dependencies]

View File

@ -1062,21 +1062,39 @@ impl SystemdCollector {
}
// Format: "/path/to/export hostname(options)" or "/path/to/export 192.168.1.0/24(options)"
// exportfs -v shows each export once per client/network
// We want to deduplicate by path and just show one entry
let parts: Vec<&str> = line.split_whitespace().collect();
// Split only at first whitespace to get path and rest
let parts: Vec<&str> = line.splitn(2, char::is_whitespace).collect();
if parts.is_empty() {
continue;
}
let export_path = parts[0].to_string();
let export_path = parts[0].trim().to_string();
// Extract options from parentheses (from the client specification)
// Find options in parentheses from the entire rest of the line
let options = if parts.len() > 1 {
let client_spec = parts[1];
if let Some(start) = client_spec.find('(') {
if let Some(end) = client_spec.find(')') {
client_spec[start+1..end].to_string()
let rest = parts[1].trim();
// Find all text in parentheses (there might be spaces before the parentheses)
if let Some(start) = rest.find('(') {
if let Some(end) = rest.find(')') {
// Extract key options only: rw/ro, sync/async
let opts = rest[start+1..end].to_string();
// Simplify options to just show key ones
let mut key_opts = Vec::new();
if opts.contains("rw") {
key_opts.push("rw");
} else if opts.contains("ro") {
key_opts.push("ro");
}
if opts.contains("sync") {
key_opts.push("sync");
} else if opts.contains("async") {
key_opts.push("async");
}
if !key_opts.is_empty() {
key_opts.join(",")
} else {
String::new()
}
} else {
String::new()
}

View File

@ -1,6 +1,6 @@
[package]
name = "cm-dashboard"
version = "0.1.272"
version = "0.1.273"
edition = "2021"
[dependencies]

View File

@ -1,6 +1,6 @@
[package]
name = "cm-dashboard-shared"
version = "0.1.272"
version = "0.1.273"
edition = "2021"
[dependencies]