From 6d11c355df2ef501f7d09a57882186b96c503e5d Mon Sep 17 00:00:00 2001 From: Roby Date: Sun, 25 Oct 2026 12:28:20 +0100 Subject: [PATCH] fix(watchdog): ridotta finestra temporale alert BER a 5 minuti Aggiornata la query di analisi diagnostica nel watchdog per calcolare la media del BER sugli ultimi 5 minuti (invece di 2 ore). Ridotto il numero minimo di transiti necessari per l'innesco, garantendo un feedback immediato nella dashboard e la scomparsa rapida dell'allarme in assenza di traffico degradato. --- services/watchdog_service.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/watchdog_service.py b/services/watchdog_service.py index 60ea3c7..ca053c5 100644 --- a/services/watchdog_service.py +++ b/services/watchdog_service.py @@ -51,7 +51,7 @@ def run_diagnostics(): cur.execute(""" SELECT LOWER(client_id), AVG(ber), COUNT(*) FROM radio_logs - WHERE timestamp >= datetime('now', 'localtime', '-2 hours') + WHERE timestamp >= datetime('now', 'localtime', '-5 minutes') AND source_id NOT LIKE '🌐%' AND (source_conn IS NULL OR LOWER(source_conn) != 'network') GROUP BY LOWER(client_id) @@ -60,7 +60,7 @@ def run_diagnostics(): for cid, avg_ber, cnt in rows: key_ber = f"{cid}_BER" - if cnt >= 5 and avg_ber is not None and avg_ber >= 5.0: + if cnt >= 2 and avg_ber is not None and avg_ber >= 5.0: new_warnings.setdefault(cid, []).append(f"⚠️ Alto BER RF ({avg_ber:.1f}%)") if not watchdog_notified.get(key_ber): broadcast_push_notification(f"⚠️ ANOMALIA RF: {cid.upper()}", f"Rilevato BER medio del {avg_ber:.1f}% negli ultimi {cnt} passaggi RF.", cid=cid)