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:
parent
f10a4e25e6
commit
77795c44d3
@ -1358,9 +1358,15 @@ impl Collector for ServiceCollector {
|
|||||||
// Measure latency for this site
|
// Measure latency for this site
|
||||||
let latency = self.measure_site_latency(site).await;
|
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 {
|
services.push(ServiceData {
|
||||||
name: site.clone(),
|
name: site.clone(),
|
||||||
status: ServiceStatus::Running, // Assume sites are running if nginx is running
|
status: site_status,
|
||||||
memory_used_mb: 0.0,
|
memory_used_mb: 0.0,
|
||||||
memory_quota_mb: 0.0,
|
memory_quota_mb: 0.0,
|
||||||
cpu_percent: 0.0,
|
cpu_percent: 0.0,
|
||||||
@ -1369,11 +1375,17 @@ impl Collector for ServiceCollector {
|
|||||||
disk_quota_gb: 0.0,
|
disk_quota_gb: 0.0,
|
||||||
is_sandboxed: false, // Sub-services inherit parent sandbox status
|
is_sandboxed: false, // Sub-services inherit parent sandbox status
|
||||||
is_sandbox_excluded: false,
|
is_sandbox_excluded: false,
|
||||||
description: None,
|
description: site_description,
|
||||||
sub_service: Some("nginx".to_string()),
|
sub_service: Some("nginx".to_string()),
|
||||||
latency_ms: latency,
|
latency_ms: latency,
|
||||||
});
|
});
|
||||||
healthy += 1;
|
|
||||||
|
// Update counters based on site status
|
||||||
|
match site_status {
|
||||||
|
ServiceStatus::Running => healthy += 1,
|
||||||
|
ServiceStatus::Stopped => failed += 1,
|
||||||
|
_ => degraded += 1,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -108,8 +108,12 @@ fn render_metrics(
|
|||||||
// Sub-services (nginx sites) only show name and status, no memory/CPU/disk data
|
// Sub-services (nginx sites) only show name and status, no memory/CPU/disk data
|
||||||
// Add latency information for nginx sites if available
|
// Add latency information for nginx sites if available
|
||||||
let service_name_with_latency = if let Some(parent) = &svc.sub_service {
|
let service_name_with_latency = if let Some(parent) = &svc.sub_service {
|
||||||
if parent == "nginx" && svc.latency_ms.is_some() {
|
if parent == "nginx" {
|
||||||
format!("{} {:.0}ms", svc.name, svc.latency_ms.unwrap())
|
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 {
|
} else {
|
||||||
svc.name.clone()
|
svc.name.clone()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user