Implement nginx site status monitoring with unreachable detection

- Show 'unreachable' status for nginx sites that fail connection tests
- Set service status to error (red) for unreachable sites
- Display latency in milliseconds for responsive sites
- Properly count failed sites in service summary statistics
- Improve nginx site monitoring reliability and visibility
This commit is contained in:
2025-10-14 20:19:39 +02:00
parent f10a4e25e6
commit 77795c44d3
2 changed files with 21 additions and 5 deletions

View File

@@ -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,
}
}
}
}