Add kernelwatch status [--json]
CI / tests (Python 3.10) (pull_request) Successful in 25s
CI / tests (Python 3.11) (pull_request) Successful in 24s
CI / tests (Python 3.12) (pull_request) Successful in 24s
CI / tests (Python 3.13) (pull_request) Successful in 25s
CI / lint (pull_request) Successful in 4s
CI / tests (Python 3.10) (pull_request) Successful in 25s
CI / tests (Python 3.11) (pull_request) Successful in 24s
CI / tests (Python 3.12) (pull_request) Successful in 24s
CI / tests (Python 3.13) (pull_request) Successful in 25s
CI / lint (pull_request) Successful in 4s
Prints the fleet like the dashboard, worst hosts first, from the same evaluate() call, so the CLI and the dashboard cannot disagree. --json gives generated_at, whole-fleet counts and a stable per-host object with no secrets; --host and --level (repeatable) trim the host list. No network surface. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9d80d3ea4c
commit
63b9151b09
4 files changed
+295
No files matched your search
@@ -453,6 +453,54 @@ 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.
|
||||
|
||||
## Scripting: `kernelwatch status`
|
||||
|
||||
`kernelwatch status` prints the fleet the way the dashboard shows it, from the
|
||||
database, with no network port or token involved. It needs `sudo`, like the other
|
||||
admin commands. Run it over SSH from anywhere else.
|
||||
|
||||
```
|
||||
$ sudo kernelwatch status
|
||||
stale new01 ? (last seen never)
|
||||
- never reported
|
||||
reboot web01 6.8.0-136 -> 6.8.0-138 (last seen 1m ago)
|
||||
- kernel: running 6.8.0-136, 6.8.0-138 installed
|
||||
- 2 security updates pending
|
||||
ok db01 6.12.57 (last seen 1m ago)
|
||||
3 hosts: 1 stale, 1 reboot, 0 update, 1 ok
|
||||
```
|
||||
|
||||
Hosts come worst first, in the dashboard's order, and use the same status logic
|
||||
(Livepatch cover, the hostname note and so on). Narrow it with `--host NAME` and
|
||||
`--level stale|reboot|update|ok` (repeatable); both also work with `--json`.
|
||||
|
||||
`--json` is for scripts. It has `generated_at`, `counts` and `hosts`. The counts
|
||||
always cover the whole fleet, and the filters only trim `hosts`. Each host has `name`,
|
||||
`status`, `reasons`, `last_report_at` (UTC ISO 8601, or `null` if it never
|
||||
reported), `last_report_age_seconds`, `os`, `kernel_running`,
|
||||
`kernel_newest_installed`, `reboot_required`, `updates_pending`,
|
||||
`security_updates`, `kernel_updates`, `services_need_restart`, `livepatch`
|
||||
(or `null`), `uptime_seconds` and `agent_version`. Fields a host hasn't
|
||||
reported are `null`, and the keys are always present. It never includes tokens
|
||||
or password hashes.
|
||||
|
||||
```sh
|
||||
# hosts that need a reboot
|
||||
sudo kernelwatch status --json | jq -r '.hosts[] | select(.status=="reboot") | .name'
|
||||
|
||||
# one line per host that needs attention, with the reasons
|
||||
sudo kernelwatch status --json --level reboot --level update |
|
||||
jq -r '.hosts[] | "\(.name): \(.reasons | join("; "))"'
|
||||
|
||||
# from your workstation; exits non-zero (for cron or a monitor) if any host is stale
|
||||
ssh triton 'sudo kernelwatch status --json' | jq -e '.counts.stale == 0' >/dev/null
|
||||
```
|
||||
|
||||
There's deliberately no HTTP endpoint for this. It would expose every host's
|
||||
kernel and pending security updates to anything holding a token, and nothing
|
||||
needs it yet. If something has to poll remotely, add one behind your proxy's
|
||||
IP allow-list rather than relying on a token alone.
|
||||
|
||||
## Heartbeat: is kernelwatch itself running?
|
||||
|
||||
Every alert above depends on `kernelwatch-alerts.timer` running on the dashboard
|
||||
@@ -500,6 +548,7 @@ sudo kernelwatch add-host NAME register a host, print its token (--token-o
|
||||
sudo kernelwatch rotate-token NAME issue a new token (old one stops working)
|
||||
sudo kernelwatch remove-host NAME delete a host and its history
|
||||
sudo kernelwatch list-hosts hosts and when they last reported
|
||||
sudo kernelwatch status [--json] fleet status like the dashboard (--host, --level to filter)
|
||||
sudo kernelwatch set-password USER create a user / change password (logs out their sessions)
|
||||
sudo kernelwatch remove-user USER
|
||||
sudo kernelwatch list-users
|
||||
|
||||
Reference in new issue
Block a user