diff --git a/README.md b/README.md index 6429aa2..fa3a272 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ Ping-only (no node_exporter): **pbs** (10.10.10.3) Served by `GET /api/attention` (`attention.py`) and refreshed with the rest of the page. - Device search (see Device pages below) - Active alerts table with severity, target, consecutive failures, ticket link -- WAN / Fiber panel: WAN and PON state, Rx/Tx power, optics temperature, throughput, errors, gateway uptime and last restart, a 24 hour internet health strip from UniFi, 7-day Rx trend, recent WAN outages +- WAN / Fiber panel: WAN and PON state, Rx/Tx power, optics temperature, throughput, errors, gateway uptime and last restart (just the last restart when the gateway doesn't report uptime), a 24 hour internet health strip from UniFi, 7-day Rx trend, recent WAN outages - Hosts with per-NIC link state; NICs marked unused fold into a "+N unused" line - UniFi devices as a compact list (name and model; offline ones turn red with a suppress button) - Recently resolved alerts, folded until opened diff --git a/static/app.js b/static/app.js index 1429f86..ef59b89 100644 --- a/static/app.js +++ b/static/app.js @@ -363,6 +363,16 @@ function _modemLastRestart(history) { return `restarted ${_modemWhen(last.at)}${last.by ? ` by ${last.by}` : ''}`; } +function _modemUptimeStat(data) { + if (data.uptime_s !== null && data.uptime_s !== undefined) { + return _modemStat('Uptime', _modemUptime(data.uptime_s), '', _modemLastRestart(data.wan_history)); + } + const restarts = (data.wan_history && data.wan_history.restarts) || []; + if (!restarts.length) return ''; + const last = restarts[restarts.length - 1]; + return _modemStat('Last restart', _modemWhen(last.at), '', last.by ? `by ${last.by}` : ''); +} + function _modemDuration(seconds) { if (seconds < 60) return `${Math.round(seconds)}s`; if (seconds < 3600) return `${Math.floor(seconds / 60)}m ${Math.round(seconds % 60)}s`; @@ -467,7 +477,7 @@ function updateModem(data) { ${_modemOptic('Optics temp', optics.temperature, status.temperature, '°C')} ${_modemStat('Throughput', `↓ ${_modemRate(rates.rx_bytes)}`, '', `↑ ${_modemRate(rates.tx_bytes)}`)} ${_modemStat('Errors / drops', `${errs} / ${drops}`, errs ? 'lt-text-amber' : '', 'since modem reboot')} - ${_modemStat('Uptime', _modemUptime(data.uptime_s), '', _modemLastRestart(data.wan_history))} + ${_modemUptimeStat(data)} ${_modemQuality(data.wan_quality)} ${_modemChart(data.history)} @@ -526,16 +536,16 @@ function updateEventsTable(events, totalActive) { : ''; return ` - ${e.severity}${supBadge}${staleBadge}${closedBadge} - ${lt.escHtml(e.event_type.replace(/_/g,' '))} - ${lt.escHtml(e.target_name)} - ${lt.escHtml(e.target_detail || '-')} - ${lt.escHtml((e.description||'').substring(0,60))}${(e.description||'').length>60?'…':''} - ${lt.time.ago(_toIso(e.first_seen))} - ${lt.time.ago(_toIso(e.last_seen))} - ${e.consecutive_failures} - ${ticket} - + ${e.severity}${supBadge}${staleBadge}${closedBadge} + ${lt.escHtml(e.event_type.replace(/_/g,' '))} + ${lt.escHtml(e.target_name)} + ${lt.escHtml(e.target_detail || '-')} + ${lt.escHtml((e.description||'').substring(0,60))}${(e.description||'').length>60?'…':''} + ${lt.time.ago(_toIso(e.first_seen))} + ${lt.time.ago(_toIso(e.last_seen))} + ${e.consecutive_failures} + ${ticket} +