Monitoring 34 NTP Synchronized Clocks from a Cron Job
说明与用途
使用 Python cron 作业监控 34 台 NTP 同步 LED 时钟,轮询其 HTTP 状态,并在偏移量超过约 1 秒时发出警报。
问题
34 wall‑clock displays across three buildings were not being monitored for time accuracy, risking incorrect time display.
结果
All 34 displays are now monitored; alerts fire when a display’s offset exceeds ~1 s or when it becomes unreachable, preventing unnoticed drift.
工作流
- 1. Verify upstream NTP server sanity with ntplib.
- 2. Define human‑perceivable offset threshold (~1 s).
- 3. Load fleet list from JSON.
- 4. Concurrently poll each device’s /status endpoint.
- 5. Normalize JSON response to internal schema.
- 6. Evaluate offset, last_sync_age, and online status.
- 7. Trigger alerts if offset > threshold or device offline.
- 8. Schedule script via cron for regular monitoring.
证据
Each unit exposes an HTTP status endpoint.
I initially monitored each display's offset from the NTP server and alerted at > 500 ms.
The shape I normalize to internally looks like this: {"id":"BLD-A-F2-REG-01",...}
- 记录日期: 2026-10-26T10:26:08.460Z