diff --git a/Cargo.lock b/Cargo.lock index 473a07c..4492033 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.29" +version = "0.1.30" dependencies = [ "anyhow", "chrono", @@ -291,7 +291,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.29" +version = "0.1.30" dependencies = [ "anyhow", "async-trait", @@ -314,7 +314,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.29" +version = "0.1.30" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 75c4d90..85fe86c 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.30" +version = "0.1.31" edition = "2021" [dependencies] diff --git a/agent/src/collectors/systemd.rs b/agent/src/collectors/systemd.rs index 231de98..0ba69e6 100644 --- a/agent/src/collectors/systemd.rs +++ b/agent/src/collectors/systemd.rs @@ -136,11 +136,10 @@ impl SystemdCollector { /// Auto-discover interesting services to monitor (internal version that doesn't update state) fn discover_services_internal(&self) -> Result<(Vec, std::collections::HashMap)> { debug!("Starting systemd service discovery with status caching"); - // Get all services (includes inactive, running, failed - everything) + // Get all service unit files (includes services that have never been started) let units_output = Command::new("systemctl") - .arg("list-units") + .arg("list-unit-files") .arg("--type=service") - .arg("--all") .arg("--no-pager") .arg("--plain") .output()?; @@ -162,23 +161,20 @@ impl SystemdCollector { for line in units_str.lines() { let fields: Vec<&str> = line.split_whitespace().collect(); - if fields.len() >= 4 && fields[0].ends_with(".service") { + if fields.len() >= 2 && fields[0].ends_with(".service") { let service_name = fields[0].trim_end_matches(".service"); + let unit_file_state = fields.get(1).unwrap_or(&"unknown").to_string(); - // Extract status information from systemctl list-units output - let load_state = fields.get(1).unwrap_or(&"unknown").to_string(); - let active_state = fields.get(2).unwrap_or(&"unknown").to_string(); - let sub_state = fields.get(3).unwrap_or(&"unknown").to_string(); - - // Cache the status information + // For unit files, we don't have runtime status info yet - will be fetched individually + // Set placeholder values for status cache (actual status will be fetched when collecting metrics) status_cache.insert(service_name.to_string(), ServiceStatusInfo { - load_state: load_state.clone(), - active_state: active_state.clone(), - sub_state: sub_state.clone(), + load_state: "unknown".to_string(), // Will be determined when we check individual status + active_state: "unknown".to_string(), // Will be determined when we check individual status + sub_state: unit_file_state.clone(), // Use unit file state as placeholder }); all_service_names.insert(service_name.to_string()); - debug!("Parsed service: {} (load:{}, active:{}, sub:{})", service_name, load_state, active_state, sub_state); + debug!("Found service unit file: {} (file_state: {})", service_name, unit_file_state); } } diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index ba22057..6b0e762 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.30" +version = "0.1.31" edition = "2021" [dependencies] diff --git a/dashboard/src/main.rs b/dashboard/src/main.rs index 21db0e0..fad9c77 100644 --- a/dashboard/src/main.rs +++ b/dashboard/src/main.rs @@ -14,7 +14,7 @@ use app::Dashboard; /// Get hardcoded version fn get_version() -> &'static str { - "v0.1.30" + "v0.1.31" } /// Check if running inside tmux session diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 9f54829..4eef960 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.30" +version = "0.1.31" edition = "2021" [dependencies]