Remove nginx site accessibility filtering to monitor all sites

- Remove check_site_accessibility function and filtering logic
- Monitor ALL nginx sites from config regardless of current status
- Site status determined by measure_site_latency, not accessibility filter
- Fixes missing git.cmtec.se when backend is down (502 errors)
- Sites with errors now show as failed instead of being filtered out
This commit is contained in:
Christoffer Martinsson 2025-10-14 22:46:06 +02:00
parent 0cb69ea8fa
commit a64464142c
2 changed files with 13 additions and 44 deletions

View File

@ -986,21 +986,11 @@ impl ServiceCollector {
}
// Check which sites are actually accessible
let mut accessible_sites = Vec::new();
for site in sites {
if self.check_site_accessibility(&site).await {
accessible_sites.push(site); // Remove checkmark - status will be shown via sub_service row status
}
}
// Limit to reasonable number
accessible_sites.truncate(15);
if accessible_sites.is_empty() {
// Return all sites from nginx config (monitor all, regardless of current status)
if sites.is_empty() {
None
} else {
Some(accessible_sites)
Some(sites)
}
}
@ -1048,34 +1038,6 @@ impl ServiceCollector {
}
}
async fn check_site_accessibility(&self, hostname: &str) -> bool {
// Create HTTP client with same timeout as site latency checks
let client = match reqwest::Client::builder()
.timeout(Duration::from_secs(2))
.build()
{
Ok(client) => client,
Err(_) => return false,
};
// Try HTTPS first, then HTTP
for scheme in ["https", "http"] {
let url = format!("{}://{}", scheme, hostname);
match client.get(&url).send().await {
Ok(response) => {
let status = response.status().as_u16();
// Check for successful HTTP status codes (same logic as before)
if status == 200 || status == 301 || status == 302 || status == 403 {
return true;
}
}
Err(_) => continue,
}
}
false
}
async fn get_nginx_description(&self) -> Option<String> {
// Get site count and active connections

View File

@ -109,10 +109,17 @@ fn render_metrics(
// Add latency information for nginx sites if available
let service_name_with_latency = if let Some(parent) = &svc.sub_service {
if parent == "nginx" {
// Extract subdomain part for shorter display
let short_name = if let Some(dot_pos) = svc.name.find('.') {
&svc.name[..dot_pos]
} else {
&svc.name
};
match &svc.latency_ms {
Some(latency) if *latency >= 2000.0 => format!("{} → unreachable", svc.name), // Timeout (2s+)
Some(latency) => format!("{}{:.0}ms", svc.name, latency),
None => format!("{} → unreachable", svc.name), // Connection failed
Some(latency) if *latency >= 2000.0 => format!("{} → unreachable", short_name), // Timeout (2s+)
Some(latency) => format!("{}{:.0}ms", short_name, latency),
None => format!("{} → unreachable", short_name), // Connection failed
}
} else {
svc.name.clone()