Add ntfy alerts for hosts that need a reboot or updates for too long #10

Merged
patrick merged 3 commits from feat/status-alerts into main 2026-10-30 00:35:03 +00:00
Owner

Summary

The alert timer now also notifies when a host has stayed in reboot or update
status past a grace period, so pending reboots and security updates no longer
depend on someone opening the dashboard.

  • Each check runs the dashboard's own evaluate() on every host's latest report.
  • A host gets one ntfy message once it has been in reboot or update for
    status_alert_after_hours (default 24, 0 disables). The message lists the
    same reasons the dashboard shows.
  • The clock starts when the host entered the status, not at its last report,
    so hourly reports don't restart it.
  • Returning to ok clears the state, so the host can alert again later.
  • update -> reboot alerts again after another grace period; reboot ->
    update does not.
  • Stale hosts are skipped; the existing stale alert covers them.
  • Failed sends are retried on the next check, and one host's failure doesn't
    block the others.

Server-side only: agents and deploy.sh are unchanged.

Changes

  • db.py: new status_alerts table (CREATE TABLE IF NOT EXISTS, so no
    migration) plus save/clear/list helpers.
  • alerts.py: _check_status(), called from check() after the stale/recovery
    pass; publish() takes an optional tag.
  • config.py / server.toml.example: status_alert_after_hours, validated as
    finite and >= 0.
  • README: alerts section, admin command description, "Ideas for later".

Upgrade notes

  • Re-run sudo ./server/install.sh; no agent redeploy needed.
  • Anyone with ntfy_url set gets these alerts by default. Set
    status_alert_after_hours = 0 to opt out.
  • Each host's clock starts at its first check after upgrading, so hosts that have
    been pending for weeks will first alert about a day later, not immediately.

Testing

make test: 104 tests pass (8 new). New tests cover the grace boundary, the
clock not resetting on new reports, one alert per episode, re-arming after a
fix, escalation vs. downgrade, stale hosts being skipped, retry after a failed
send, and 0 disabling. Not yet tried against a live ntfy topic.

🤖 Generated with Claude Code

## Summary The alert timer now also notifies when a host has stayed in `reboot` or `update` status past a grace period, so pending reboots and security updates no longer depend on someone opening the dashboard. - Each check runs the dashboard's own `evaluate()` on every host's latest report. - A host gets one ntfy message once it has been in `reboot` or `update` for `status_alert_after_hours` (default 24, `0` disables). The message lists the same reasons the dashboard shows. - The clock starts when the host *entered* the status, not at its last report, so hourly reports don't restart it. - Returning to `ok` clears the state, so the host can alert again later. - `update` -> `reboot` alerts again after another grace period; `reboot` -> `update` does not. - Stale hosts are skipped; the existing stale alert covers them. - Failed sends are retried on the next check, and one host's failure doesn't block the others. Server-side only: agents and `deploy.sh` are unchanged. ## Changes - `db.py`: new `status_alerts` table (`CREATE TABLE IF NOT EXISTS`, so no migration) plus save/clear/list helpers. - `alerts.py`: `_check_status()`, called from `check()` after the stale/recovery pass; `publish()` takes an optional `tag`. - `config.py` / `server.toml.example`: `status_alert_after_hours`, validated as finite and >= 0. - README: alerts section, admin command description, "Ideas for later". ## Upgrade notes - Re-run `sudo ./server/install.sh`; no agent redeploy needed. - Anyone with `ntfy_url` set gets these alerts by default. Set `status_alert_after_hours = 0` to opt out. - Each host's clock starts at its first check after upgrading, so hosts that have been pending for weeks will first alert about a day later, not immediately. ## Testing `make test`: 104 tests pass (8 new). New tests cover the grace boundary, the clock not resetting on new reports, one alert per episode, re-arming after a fix, escalation vs. downgrade, stale hosts being skipped, retry after a failed send, and `0` disabling. Not yet tried against a live ntfy topic. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
patrick added 3 commits 2026-10-30 00:33:43 +00:00
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The alert timer now evaluates each host with the dashboard's status logic
and sends one ntfy message once a host has been in reboot or update for
status_alert_after_hours, measured from when it entered that status.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Document reboot and update alerts
CI / tests (Python 3.10) (pull_request) Successful in 19s
CI / tests (Python 3.11) (pull_request) Successful in 18s
CI / tests (Python 3.12) (pull_request) Successful in 17s
CI / tests (Python 3.13) (pull_request) Successful in 17s
CI / lint (pull_request) Successful in 3s
b6957e3ca4
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
patrick merged commit c67a8e27a0 into main 2026-10-30 00:35:03 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: patrick/kernel-automation#10