#!/usr/bin/env python """monitor_health.py โ€” i forward-monitor stanno registrando? Riporta e allerta, non tocca nulla. Tre gate pre-registrati (STATARB 27/09, XSR01 23/10, DVOLSPREAD 24/10) si decideranno leggendo serie forward che, tranne una, **nessuno sorvegliava**. Un monitor fermo produce silenzio, e il silenzio in una serie di ritorni si legge come "zero", cioe' come una misura. Non lo e'. Vedi `src/live/monitor_health.py` per le due misure (coda + buchi interni), le cadenze per monitor e la soglia di copertura 0.80 (la stessa del veto d'integrita' di DVOLSPREAD). uv run python scripts/live/monitor_health.py # report uv run python scripts/live/monitor_health.py --quiet # stampa/allerta solo se scatta """ from __future__ import annotations import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[2] sys.path.insert(0, str(ROOT)) from src.live.monitor_health import MIN_COVERAGE, alerts_from, check_all # noqa: E402 from src.live.notifier import notify # noqa: E402 def main() -> int: rows = check_all(ROOT) alerts = alerts_from(rows) if "--quiet" not in sys.argv or alerts: print("=" * 92) print(" MONITOR HEALTH โ€” i forward-monitor stanno ancora registrando?") print("=" * 92) print(f"\n {'monitor':<20}{'stato':>10}{'barre':>8}{'attese':>8}" f"{'copert.':>10}{'eta ultima':>13} gate che ne dipende") for r in rows: cov = f"{r['coverage']:.0%}" if r["coverage"] is not None else "-" exp = f"{r['expected']}" if r["expected"] is not None else "-" age = f"{r['age_h']:.0f}h" if r["age_h"] is not None else "-" gate = (r["gate"] or "").split(" โ€” ")[0] print(f" {r['name']:<20}{r['status']:>10}{r['n_bars']:>8}{exp:>8}" f"{cov:>10}{age:>13} {gate}") print(f"\n soglia di copertura {MIN_COVERAGE:.0%} (= veto d'integrita' di DVOLSPREAD) ยท " f"'NUOVO' = troppo giovane per un giudizio, non 'OK'") for r in rows: if r["why"] and r["status"] != "OK": print(f" {r['name']}: {r['why']}") if alerts: notify("๐Ÿฉบ MONITOR HEALTH โ€” un forward-monitor non sta registrando", {f"alert {i+1}": a for i, a in enumerate(alerts)}) for a in alerts: print(f" ALERT: {a}") return 2 return 0 if __name__ == "__main__": raise SystemExit(main())