New features: stale banner, tab title alerts, health checks, DB housekeeping
static/app.js: - Browser tab title updates to show alert count: '(3 CRIT) GANDALF' or '(2 WARN) GANDALF' - Stale monitoring banner: injected into .main if last_check > 15 min old, warns operator that the monitor daemon may be down static/style.css: - .stale-banner: amber top-border warning strip app.py: - /health now checks DB connectivity and monitor freshness (last_check age) Returns 503 + degraded status if DB unreachable or monitor stale >20min db.py: - cleanup_expired_suppressions(): marks time-limited suppressions inactive when expires_at <= NOW() (was only filtered in SELECTs, never marked inactive) - purge_old_resolved_events(days=90): deletes old resolved events to prevent unbounded table growth monitor.py: - Calls cleanup_expired_suppressions() and purge_old_resolved_events() each cycle Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -49,6 +49,37 @@ function updateStatusBar(summary, lastCheck) {
|
||||
|
||||
const lc = document.getElementById('last-check');
|
||||
if (lc && lastCheck) lc.textContent = lastCheck;
|
||||
|
||||
// Update browser tab title with alert count
|
||||
const critCount = summary.critical || 0;
|
||||
const warnCount = summary.warning || 0;
|
||||
if (critCount) {
|
||||
document.title = `(${critCount} CRIT) GANDALF`;
|
||||
} else if (warnCount) {
|
||||
document.title = `(${warnCount} WARN) GANDALF`;
|
||||
} else {
|
||||
document.title = 'GANDALF';
|
||||
}
|
||||
|
||||
// Stale data banner: warn if last_check is older than 15 minutes
|
||||
let staleBanner = document.getElementById('stale-banner');
|
||||
if (lastCheck) {
|
||||
// last_check format: "2026-03-14 14:14:21 UTC"
|
||||
const checkAge = (Date.now() - new Date(lastCheck.replace(' UTC', 'Z').replace(' ', 'T'))) / 1000;
|
||||
if (checkAge > 900) { // 15 minutes
|
||||
if (!staleBanner) {
|
||||
staleBanner = document.createElement('div');
|
||||
staleBanner.id = 'stale-banner';
|
||||
staleBanner.className = 'stale-banner';
|
||||
document.querySelector('.main').prepend(staleBanner);
|
||||
}
|
||||
const mins = Math.floor(checkAge / 60);
|
||||
staleBanner.textContent = `⚠ Monitoring data is stale — last check was ${mins} minute${mins !== 1 ? 's' : ''} ago. The monitor daemon may be down.`;
|
||||
staleBanner.style.display = '';
|
||||
} else if (staleBanner) {
|
||||
staleBanner.style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateHostGrid(hosts) {
|
||||
|
||||
Reference in New Issue
Block a user