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
2 changed files with 19 additions and 3 deletions
Showing only changes of commit b6957e3ca4 - Show all commits

No files matched your search

+13 -3
View File
@@ -369,7 +369,7 @@ Host zeus
ProxyJump eurus ProxyJump eurus
``` ```
## Stale-host and recovery alerts (ntfy) ## Stale-host, reboot and update alerts (ntfy)
The server can notify an [ntfy](https://ntfy.sh/) topic when a host stops 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 reporting and when its reports resume. Agents report hourly with up to 15 minutes
@@ -413,6 +413,16 @@ fresh report. Run `sudo kernelwatch check-alerts` to check immediately, or inspe
`stale_after_hours`, restart `kernelwatch.service` too so the dashboard uses the `stale_after_hours`, restart `kernelwatch.service` too so the dashboard uses the
new threshold. 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 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 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). in the server config (root-owned, readable by the `kernelwatch` service group).
@@ -428,7 +438,7 @@ sudo kernelwatch list-hosts hosts and when they last reported
sudo kernelwatch set-password USER create a user / change password (logs out their sessions) sudo kernelwatch set-password USER create a user / change password (logs out their sessions)
sudo kernelwatch remove-user USER sudo kernelwatch remove-user USER
sudo kernelwatch list-users sudo kernelwatch list-users
sudo kernelwatch check-alerts check for stale hosts and reporting recovery now sudo kernelwatch check-alerts check for stale, recovered, reboot and update alerts now
sudo kernelwatch test-alert send a test notification to the configured ntfy topic sudo kernelwatch test-alert send a test notification to the configured ntfy topic
``` ```
@@ -483,7 +493,7 @@ export KERNELWATCH_CONFIG=/tmp/kw.toml
## Ideas for later ## Ideas for later
- Notifications for pending updates/reboots, and additional delivery channels - Additional notification channels
- Ubuntu Livepatch / Pro status, so live-patched hosts aren't flagged for reboot - Ubuntu Livepatch / Pro status, so live-patched hosts aren't flagged for reboot
- A JSON endpoint for scripting - A JSON endpoint for scripting
- Grouping or tagging hosts (prod/staging, location) - Grouping or tagging hosts (prod/staging, location)
+6
View File
@@ -31,3 +31,9 @@ trust_proxy_headers = false
ntfy_url = "" # e.g. "https://ntfy.example.com/kernelwatch" ntfy_url = "" # e.g. "https://ntfy.example.com/kernelwatch"
ntfy_token = "" # optional ntfy access token (Bearer auth) ntfy_token = "" # optional ntfy access token (Bearer auth)
ntfy_timeout_seconds = 10.0 ntfy_timeout_seconds = 10.0
# Also notify (once) when a host has needed a reboot or updates for this long.
# Measured from when the host entered that state, not from its latest report.
# Reaching a worse state (updates -> reboot) notifies again after another period.
# 0 disables. Needs ntfy_url.
status_alert_after_hours = 24.0