From 7f26991609bf97808a241980524b1d0a9f970539 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Mon, 24 Nov 2025 23:01:51 +0100 Subject: [PATCH] Fix nginx sub-services flickering with persistent caching - Remove nginx_ prefix from site names in hierarchical structure - Fix get_nginx_site_metrics to call correct internal method - Implement same caching functionality as old working version - Sites now stay visible continuously with 30s latency updates - Preserve cached results between refresh cycles --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- agent/src/collectors/systemd.rs | 8 ++++---- dashboard/Cargo.toml | 2 +- shared/Cargo.toml | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5234947..0544753 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.145" +version = "0.1.146" dependencies = [ "anyhow", "chrono", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.145" +version = "0.1.146" dependencies = [ "anyhow", "async-trait", @@ -324,7 +324,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.145" +version = "0.1.146" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 7213218..e708893 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.146" +version = "0.1.147" edition = "2021" [dependencies] diff --git a/agent/src/collectors/systemd.rs b/agent/src/collectors/systemd.rs index b30accd..3c4aa41 100644 --- a/agent/src/collectors/systemd.rs +++ b/agent/src/collectors/systemd.rs @@ -101,7 +101,7 @@ impl SystemdCollector { let mut sub_services = Vec::new(); - // Collect sub-services for specific services + // Sub-service metrics for specific services (always include cached results) if service_name.contains("nginx") && active_status == "active" { let nginx_sites = self.get_nginx_site_metrics(); for (site_name, latency_ms) in nginx_sites { @@ -216,7 +216,7 @@ impl SystemdCollector { Ok(state.monitored_services.clone()) } - /// Get nginx site metrics, checking them if cache is expired + /// Get nginx site metrics, checking them if cache is expired (like old working version) fn get_nginx_site_metrics(&self) -> Vec<(String, f32)> { let mut state = self.state.write().unwrap(); @@ -574,11 +574,11 @@ impl SystemdCollector { for (site_name, url) in &discovered_sites { match self.check_site_latency(url) { Ok(latency_ms) => { - sites.push((format!("nginx_{}", site_name), latency_ms)); + sites.push((site_name.clone(), latency_ms)); } Err(_) => { // Site is unreachable - use -1.0 to indicate error - sites.push((format!("nginx_{}", site_name), -1.0)); + sites.push((site_name.clone(), -1.0)); } } } diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index a56e07e..02a0621 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.146" +version = "0.1.147" edition = "2021" [dependencies] diff --git a/shared/Cargo.toml b/shared/Cargo.toml index bfa01b0..76d1112 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.146" +version = "0.1.147" edition = "2021" [dependencies]