Files
kernel-automation/docs/alerts.md
T
patrickandClaude Sonnet 5.5 77a880880a Move README sections into docs/ pages
Content is moved verbatim (checked line by line against the old README). Each
page gets a title and a link back to the README; H3 sections that become pages
of their own are promoted to H2. The README itself is trimmed next.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 12:07:31 -04:00

5.0 KiB

Alerts and monitoring

← kernelwatch

Stale-host, reboot and update alerts (ntfy)

The server can notify an ntfy topic when a host stops reporting and when its reports resume. Agents report hourly with up to 15 minutes of jitter. Alerts use the same stale_after_hours as the dashboard (3 hours by default), leaving room for ordinary delays. Newly registered hosts get that same grace period to send their first report.

Re-run sudo ./server/install.sh to install the alert timer when upgrading. The installer preserves your existing config, so add these settings to /etc/kernelwatch/server.toml:

ntfy_url = "https://ntfy.example.com/kernelwatch"
ntfy_token = ""  # optional access token with publish permission for this topic
ntfy_timeout_seconds = 10.0

Subscribe to that topic in your ntfy app, then check delivery:

sudo kernelwatch test-alert
systemctl list-timers kernelwatch-alerts.timer

kernelwatch-alerts.timer runs a separate, unprivileged check every five minutes, even when no hosts report and nobody opens the dashboard. Notifications normally arrive within about five minutes of crossing the stale threshold or receiving a fresh report. Run sudo kernelwatch check-alerts to check immediately, or inspect journalctl -u kernelwatch-alerts.service for delivery failures.

  • Each host gets one stale notification and one reporting-recovery notification per detected outage. Successful sends are saved in SQLite, so routine checks and server restarts don't repeat them. Recovery confirms reporting has resumed; the host may still need updates or a reboot.

  • Failed sends are retried on the next check, and a failure for one host doesn't stop checks for the others. A recovery is sent only after a stale notification was successfully delivered. A timeout or crash after ntfy accepted a message can cause a duplicate on retry.

  • An empty ntfy_url disables notifications. The timer reads its configuration on every run; changing ntfy settings needs no restart. If you change stale_after_hours, restart kernelwatch.service too so the dashboard uses the new threshold.

  • Reboot and update alerts. A host that has stayed in reboot or update for status_alert_after_hours (default 24) gets one notification listing the reasons shown on the dashboard. The clock starts when the host entered that status, so hourly reports don't restart it. Fixing the host (back to ok) re-arms it. Going from update to reboot notifies again after another period; going back down doesn't. Stale hosts are skipped, since the stale alert covers them. Set status_alert_after_hours = 0 to turn these off. Upgrading starts the clock at the first check, so expect the first notifications a day after you re-run install.sh.

Use the topic's direct publish URL, with token authentication if needed; it must accept the POST without a browser login or redirect. The topic and token stay in the server config (root-owned, readable by the kernelwatch service group). Agents need no changes.

Heartbeat: is kernelwatch itself running?

Every alert above depends on kernelwatch-alerts.timer running on the dashboard host. If that host is down, or the timer breaks, nothing tells you. A heartbeat fixes this: kernelwatch pings an external monitor, and the monitor alerts when the pings stop. healthchecks.io has a free tier; Uptime Kuma's push monitors work the same way.

  1. In the monitor, create two checks and copy their ping URLs:

    • alerts: period 5 minutes, grace 20 minutes.
    • backup: period 1 day, grace a few hours (the timer fires about 03:30 and can be up to 30 minutes late).
  2. Add the URLs to /etc/kernelwatch/server.toml (no restart needed for the alert check or the backup; they read it on every run):

    heartbeat_url = "https://hc-ping.com/<uuid>"
    backup_heartbeat_url = "https://hc-ping.com/<other-uuid>"
    
  3. Check both: sudo kernelwatch test-heartbeat pings each configured URL once.

What counts as a heartbeat:

  • heartbeat_url is pinged at the end of every alert check (every five minutes) that sent all its notifications. If ntfy delivery is failing, the ping is skipped on purpose, so the monitor also notices a broken alert pipeline. It's pinged even with no ntfy_url, since the timer is still alive.
  • backup_heartbeat_url is pinged after each successful nightly backup, so a timer that never ran, or a backup that failed, shows up as a missing ping. A manual kernelwatch backup doesn't ping.
  • A heartbeat that can't be delivered is logged (status code or error type, never the URL) and never fails the check or the backup.

The pings leave from the dashboard host, so a dead host is exactly what stops them. Set the monitor to notify you some way that doesn't depend on that host: email, the monitor's own app, or ntfy.sh. Not a ntfy server running behind it. The URLs are secrets (whoever has one can fake a heartbeat), so keep server.toml readable by root and the kernelwatch group only.