diff --git a/agent/src/collectors/service.rs b/agent/src/collectors/service.rs index c3620ca..ae4758a 100644 --- a/agent/src/collectors/service.rs +++ b/agent/src/collectors/service.rs @@ -1358,9 +1358,15 @@ impl Collector for ServiceCollector { // Measure latency for this site let latency = self.measure_site_latency(site).await; + // Determine status and description based on latency measurement + let (site_status, site_description) = match latency { + Some(ms) => (ServiceStatus::Running, None), + None => (ServiceStatus::Stopped, Some(vec!["unreachable".to_string()])), + }; + services.push(ServiceData { name: site.clone(), - status: ServiceStatus::Running, // Assume sites are running if nginx is running + status: site_status, memory_used_mb: 0.0, memory_quota_mb: 0.0, cpu_percent: 0.0, @@ -1369,11 +1375,17 @@ impl Collector for ServiceCollector { disk_quota_gb: 0.0, is_sandboxed: false, // Sub-services inherit parent sandbox status is_sandbox_excluded: false, - description: None, + description: site_description, sub_service: Some("nginx".to_string()), latency_ms: latency, }); - healthy += 1; + + // Update counters based on site status + match site_status { + ServiceStatus::Running => healthy += 1, + ServiceStatus::Stopped => failed += 1, + _ => degraded += 1, + } } } } diff --git a/dashboard/src/ui/services.rs b/dashboard/src/ui/services.rs index 52ffdf0..a134f7a 100644 --- a/dashboard/src/ui/services.rs +++ b/dashboard/src/ui/services.rs @@ -108,8 +108,12 @@ fn render_metrics( // Sub-services (nginx sites) only show name and status, no memory/CPU/disk data // Add latency information for nginx sites if available let service_name_with_latency = if let Some(parent) = &svc.sub_service { - if parent == "nginx" && svc.latency_ms.is_some() { - format!("{} {:.0}ms", svc.name, svc.latency_ms.unwrap()) + if parent == "nginx" { + match (&svc.latency_ms, &svc.description) { + (Some(latency), _) => format!("{} {:.0}ms", svc.name, latency), + (None, Some(desc)) if !desc.is_empty() => format!("{} {}", svc.name, desc[0]), + _ => svc.name.clone(), + } } else { svc.name.clone() }