# Alerts and monitoring [← kernelwatch](../README.md) ntfy notifications for stale hosts, pending reboots and updates, plus heartbeat monitoring so you find out if kernelwatch itself stops. ## Stale-host, reboot and update alerts (ntfy) The server can notify an [ntfy](https://ntfy.sh/) 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`: ```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: ```sh 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`. - **Livepatch alerts.** On Ubuntu hosts using [Livepatch](how-it-works.md), a host whose live patching has been broken for `livepatch_alert_after_hours` (default 6) gets one high-priority notification: an unhealthy state (not `applied` or `nothing-to-apply`), a failed check, or an unsupported kernel. It also fires when a host that *used to* report Livepatch stops, which is what a dead Livepatch daemon looks like, since the agent then has nothing to send. Hosts that have never reported Livepatch never alert. As with the other alerts it's once per problem; getting healthy again re-arms it, and a brief blip that clears within the period sends nothing. Stale hosts are skipped. A host where you turn Livepatch off on purpose sends one message and then stays quiet. `livepatch_alert_after_hours = 0` turns these off. 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](https://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): ```toml heartbeat_url = "https://hc-ping.com/" backup_heartbeat_url = "https://hc-ping.com/" ``` 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.