Fix nginx sub-services flickering with persistent caching
All checks were successful
Build and Release / build-and-release (push) Successful in 1m19s

- 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
This commit is contained in:
2025-11-24 23:01:51 +01:00
parent 75ec190b93
commit 7f26991609
5 changed files with 10 additions and 10 deletions

View File

@@ -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));
}
}
}