Report devices seen on last scan in ARP/SNMP status

The ARP and SNMP scanner status endpoints and front-end cards now expose
the number of devices found by the most recent successful scan, following
the existing mDNS device-count pattern. The count persists across the
running/waiting transitions, and for SNMP a failed poll keeps the last
good count rather than overwriting it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
rzuasti
2026-06-02 08:45:45 -04:00
co-authored by Claude Opus 4.8
parent 38158a4ffc
commit d15411a889
11 changed files with 118 additions and 13 deletions
+10
View File
@@ -11,6 +11,10 @@ pub struct SnmpScannerStatusResponse {
pub running_for_seconds: Option<f64>,
/// Seconds until the next poll starts (only set when is_running is false; clamped to 0)
pub next_run_in_seconds: Option<f64>,
/// Number of devices found by the last successful scan (None if none completed yet)
pub last_scan_devices_seen: Option<u64>,
/// Seconds since the last successful scan completed (None if none completed yet)
pub last_scan_seconds_ago: Option<f64>,
}
#[utoipa::path(
@@ -47,9 +51,15 @@ pub async fn status() -> Result<Json<SnmpScannerStatusResponse>, StatusCode> {
(None, next_run_in)
};
let last_scan_seconds_ago = snapshot
.last_scan_at
.map(|t| ((now - t).num_milliseconds() as f64 / 1000.0).max(0.0));
Ok(Json(SnmpScannerStatusResponse {
is_running: snapshot.is_running,
running_for_seconds,
next_run_in_seconds,
last_scan_devices_seen: snapshot.last_scan_devices_seen,
last_scan_seconds_ago,
}))
}