17 Commits
Author SHA1 Message Date
patrickandClaude Opus 5.5 15b1f5be4f Flag hosts without room on disk for their pending upgrades
CI / tests (Python 3.10) (pull_request) Successful in 43s
CI / tests (Python 3.11) (pull_request) Successful in 44s
CI / tests (Python 3.12) (pull_request) Successful in 43s
CI / tests (Python 3.13) (pull_request) Successful in 42s
CI / lint (pull_request) Successful in 3s
A filesystem that fills up while apt downloads or dpkg unpacks leaves the
upgrade half-done and apt broken, the same failure as a full /boot but on
/ or /var. Nothing caught it until the host's updates stopped.

The agent (0.11.0) now works out what the pending upgrades need. A
simulation doesn't print apt's "Need to get" or "additional disk space"
lines, so it sums the package records from apt-cache show for each version
the simulation would install: Size for each .deb not already in
/var/cache/apt/archives, and the growth in Installed-Size over the
installed versions (from dpkg-query). Removals aren't subtracted, so it
errs high. It also reports free space and the mount point of the
filesystems holding /var/cache/apt/archives and /usr.

The server puts a host in update when the upgrades would leave less than
upgrade_min_free_mb (default 100, 0 disables) on either filesystem. The
download and the install both count when they're on the same one. With
nothing pending there is nothing to check, so this doesn't turn into
general disk monitoring. The host page gets a "Pending upgrades size" row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 20:16:54 -05:00
patrickandClaude Opus 5.5 8174f1df81 Put hosts with unloaded CPU microcode updates in reboot
CI / tests (Python 3.11) (pull_request) Successful in 39s
CI / tests (Python 3.12) (pull_request) Successful in 38s
CI / tests (Python 3.13) (pull_request) Successful in 38s
CI / lint (pull_request) Failing after 3s
CI / tests (Python 3.10) (pull_request) Successful in 40s
On bare metal, needrestart -b reports NEEDRESTART-UCSTA: 2 when the
installed intel-microcode/amd64-microcode is newer than what the CPU
loaded at boot, which only a reboot fixes. The agent dropped those
lines. It now reports needrestart_ucsta, _uccur and _ucexp, and the
server puts the host in reboot with both revisions. Livepatch doesn't
cover it. needrestart skips the check in VMs, so only physical hosts
(debian-homelab today) report it; the host page gets a "CPU microcode"
row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 15:25:57 -05:00
patrickandClaude Opus 5.5 4676942108 Report packages on hold, and flag held kernel packages
A held package never upgrades, and apt's simulation leaves it out, so
its updates (security ones included) appear nowhere. A leftover hold on
linux-image-amd64 or linux-generic keeps a host on its kernel while it
looks current.

The agent reports installed held packages (dpkg's "hi") as
held_packages. A held linux-* package puts the host in update with the
apt-mark unhold hint; other holds, usually deliberate, get a note. The
host page lists them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 15:24:27 -05:00
patrickandClaude Opus 5.5 f88261d2f5 Report when kernelwatch's own helper units keep failing
kernelwatch-apt-update.service failed hourly on most hosts for weeks
without anything showing it. The agent only Wants= its helper units, so
the report goes out regardless, with stale lists or (for needrestart)
results that quietly turn "unknown".

Each helper (apt-update, needrestart) now runs kernelwatch-unit-result
as its ExecStopPost=, which systemd runs after failed runs too. It
writes "RESULT EXIT_CODE EXIT_STATUS FAILURES" to
/run/kernelwatch/<name>.result, FAILURES counting failed runs in a row.
The agent (0.10.0) reports results from the last two hours as
helper_units. On the server, one or two failures are a note (an admin's
apt can hold the lock now and then); three in a row put the host in
update, naming the unit and its exit status and pointing at journalctl.
The host page gets a "kernelwatch helpers" row.

The Livepatch unit isn't tracked: it fails by design where the snap is
installed but Livepatch isn't enabled, and Livepatch has its own check.

The apt-update unit now has RuntimeDirectory=kernelwatch (preserved,
like the others) for its result file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 15:23:05 -05:00
patrickandClaude Opus 5.5 c9912d5fbc Check that the release's security repository is configured and fresh
CI / tests (Python 3.10) (pull_request) Successful in 36s
CI / tests (Python 3.11) (pull_request) Successful in 36s
CI / tests (Python 3.12) (pull_request) Successful in 37s
CI / tests (Python 3.13) (pull_request) Successful in 37s
CI / lint (pull_request) Successful in 4s
security_count is only meaningful if apt has the release's security
suite. A host missing it from its sources shows 0 security updates
forever, and one whose apt can't fetch it (expired key, wrong URL after
a release upgrade, a mirror that fell behind) keeps the last copy while
the update stamps and other lists move on, so neither the simulation nor
the package list age notices.

The agent (0.9.0) now finds apt's list for <codename>-security by its
Suite: (Ubuntu) or Codename: (Debian) field, since file names depend on
the mirror (mirror+file: sources, several mirrors), and reports
security_repo_suite and security_repo_age_seconds from its Date:, the
newest copy winning. The server puts the host in update when there's no
such list, or when it's older than security_repo_stale_after_days
(default 7) while the package lists are otherwise fresh; if all of
them are old, the existing "package lists N days old" reason covers
it. Releases past the end of support are skipped: their suite has
stopped publishing, and support.check already says so. ESM suites
publish too rarely to judge by date and aren't checked.

The host page gets a "Security repository" row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 14:58:10 -05:00
patrickandClaude Opus 5.5 bfac723850 Flag hosts where unattended-upgrades has stopped succeeding
On a host with unattended-upgrades enabled, no successful run in
unattended_upgrades_stale_after_days (default 3, 0 disables) puts it in
update. The reason says which way it broke: still running but failing
("last succeeded 5d ago and is failing (last ran 6h ago); check
/var/log/unattended-upgrades/"), not running at all ("is
apt-daily-upgrade.timer enabled?"), or never succeeded. A host where it
hasn't completed its first run yet gets a note, and packages it keeps back
are noted. Hosts with it disabled or not installed, and agents before
0.8.0, are judged as before. The host page shows the state, both stamp
ages and the kept-back packages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 20:18:41 -04:00
patrickandClaude Opus 5.5 bc46c55298 Flag hosts whose OS release no longer gets security updates
CI / tests (Python 3.10) (pull_request) Successful in 30s
CI / tests (Python 3.11) (pull_request) Successful in 30s
CI / tests (Python 3.12) (pull_request) Successful in 28s
CI / tests (Python 3.13) (pull_request) Successful in 28s
CI / lint (pull_request) Successful in 3s
Past its end of support a release gets no more security updates, so apt
offers nothing and the host showed ok indefinitely. The server now has a
table of when free security support ends for each release the agent
installs on (support.py): Debian's LTS end, and Ubuntu's end of standard
support plus end of ESM. Dates from Debian LTS and Ubuntu's release cycle
via endoflife.date; a test checks the table covers every release
agent/install.sh accepts.

The agent reports whether Ubuntu Pro is attached and esm-infra's status,
read from the pro client's world-readable status.json. A host past its
date goes to update; within os_eol_warn_days (default 90) of it, the row
gets a note. An Ubuntu host with ESM enabled isn't warned when standard
support ends, only before ESM does. The host page shows the dates.
Agent 0.7.0; older agents don't report ESM and count as having none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 19:50:44 -04:00
patrickandClaude Opus 5.5 70272efed5 Flag a /boot too full for the next kernel and packages dpkg left unfinished
CI / tests (Python 3.10) (pull_request) Successful in 29s
CI / tests (Python 3.11) (pull_request) Successful in 30s
CI / tests (Python 3.12) (pull_request) Successful in 29s
CI / tests (Python 3.13) (pull_request) Successful in 28s
CI / lint (pull_request) Successful in 4s
A full /boot makes the next kernel's postinst fail: apt is left half-done
and the host quietly stays on its old kernel, which kernelwatch only
noticed indirectly, if at all. The agent now reports the size and free
space of the filesystem holding /boot (df) and the packages dpkg didn't
finish installing (half-installed, unpacked, half-configured, trigger
states or reinst-required, as dpkg --audit counts them).

The server puts a host in update when /boot has less than
boot_min_free_mb (default 200, 0 disables) free, or any package is
unfinished, with the fix in the reason ("run dpkg --configure -a"). The
host page shows both. Agents before 0.6.0 send neither field and are
judged as before. Agent 0.6.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 18:54:47 -04:00
patrickandClaude Opus 5.5 6d29197cfc Report a failed apt simulation instead of reading it as "no updates"
CI / tests (Python 3.10) (pull_request) Successful in 26s
CI / tests (Python 3.11) (pull_request) Successful in 25s
CI / tests (Python 3.12) (pull_request) Successful in 25s
CI / tests (Python 3.13) (pull_request) Successful in 25s
CI / lint (pull_request) Failing after 3s
The agent ran `apt-get -s dist-upgrade 2>/dev/null || true`, so when apt
failed (unmet dependencies, a broken sources entry, a damaged package cache)
the empty output counted as zero updates and the host could show ok while
nothing could be installed. The agent now keeps apt's exit status and stderr,
reports apt_simulation_ok and the first "E:" line as apt_simulation_error,
and sends the update counts as null. The server puts such a host in update
with "apt can't work out pending updates: ...", and the host page shows the
result. Agents before 0.5.0 don't send the field and are judged as before.

Also show "–" rather than "None" for an unknown count in a host's history,
and stop hard-coding the agent version in the status CLI tests. Agent 0.5.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 23:22:24 -04:00
patrickandClaude Sonnet 5.5 4fa86de11f Treat Ubuntu Livepatch as cover for pending kernel reboots
New livepatch_* report fields. When Livepatch is healthy (applied or
nothing-to-apply, checked, supported) and the kernel's support end date is
more than 14 days away, a pending kernel reboot, or a reboot-required file
caused only by linux-* packages, becomes a note instead of the reboot status.
Anything else about Livepatch gives no cover and is noted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 21:35:42 -04:00
patrickandClaude Sonnet 5.5 63ca790779 Flag hosts whose reported hostname differs from their registered name
A note on the dashboard row and host page, not a status change, so a token
copied to the wrong machine is visible. Only the first DNS label is compared,
ignoring case, since registered names are usually hostname -s and the agent
reports hostname -f.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 21:17:40 -04:00
patrickandClaude Sonnet 5.5 a6a43b142f Rate-limit report ingestion per host
Reports arriving sooner than report_min_interval_seconds (default 30) after
the host's previous one are refused with 429 and a Retry-After header. The
check shares the insert's transaction so concurrent requests can't bypass it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 20:46:09 -04:00
patrickandClaude Opus 5.5 45af8bc1f8 Give phased updates their own dashboard column
The "+N phased" suffix in the Updates cell was easy to miss and only
appeared when something was deferred. Add a Phased column instead:
the count (hover for the packages), "0" when nothing is deferred, "–"
on distributions that don't phase (Debian), "?" for agents too old to
report it. Dashboard-only; no agent redeploy needed. Server 0.3.1.

Also list Ubuntu 26.04 as tested in the agent installer and README
(already reporting fine from a 26.04 host).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 13:09:15 -04:00
patrickandClaude Opus 5.5 271af3b071 Show Ubuntu phased updates separately from available updates
apt lists updates deferred by phasing in an indented block rather than
as Inst lines, so they were already excluded from the counts but
invisible. The agent now parses that block into phased_packages; the
dashboard shows "+N phased" in the Updates column (with a tooltip) and
the list on the host page. Phasing never affects status: Ubuntu doesn't
phase security updates, and there's nothing to act on until apt offers
the update.

Run the apt simulation with LC_ALL=C since we parse its messages (the
systemd unit already runs in the C locale; manual --print may not).
Agent and server 0.3.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 12:03:02 -04:00
patrickandClaude Opus 5.5 834c1459c0 Report services needing a restart via a separate root needrestart unit
needrestart has to inspect every process, which an unprivileged agent
can't (and unprivileged it gave false kernel results). Add
kernelwatch-needrestart.service: root with only CAP_SYS_PTRACE and
CAP_DAC_READ_SEARCH, PrivateNetwork=yes, list-only (-r l). It writes
`needrestart -b` output to /run/kernelwatch/needrestart; the agent unit
pulls it in before each report and reads the file (ignored if older than
2h). The agent no longer runs needrestart itself. Skipped cleanly when
needrestart isn't installed: the dashboard shows "?" and status is
unaffected.

Server: services_need_restart / sessions_need_restart fields, an
"update"-level reason, a Services column, and a note (not an escalation)
for hosts running an agent older than the one shipped with the server.

install.sh --with-needrestart installs needrestart and sets it to list
services after apt upgrades instead of prompting; deploy.sh passes
anything after `--` to install.sh. Agent 0.2.0, server 0.2.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 11:54:39 -04:00
patrickandClaude Opus 5.5 48f2d155af Run the agent unprivileged; detect in-place kernel upgrades
The agent ran as (capability-less) root only so needrestart could read
Ubuntu's root-only /boot images. Switch the unit to DynamicUser=yes and
make needrestart optional.

To cover the case needrestart was catching (running kernel's package
upgraded in place, same uname -r), the agent now reports the installed
package version of the running kernel and the server compares it with
the build in uname -v: "Debian 6.12.57-1" vs 6.12.57-1 on Debian,
"#85-Ubuntu" / "#33~24.04.1-Ubuntu" vs the upload part of 6.8.0-85.85 /
6.14.0-33.33~24.04.1 on Ubuntu. Unrecognised builds fall back to
needrestart and the newest-installed comparison.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 10:19:41 -04:00
patrickandClaude Opus 5.5 07749b01b0 Scaffold kernelwatch: fleet kernel status agent and dashboard
Agent: bash script run hourly by a hardened systemd timer on Debian 12/13
and Ubuntu 24.04. Collects running vs installed kernel (needrestart when
available), pending/security updates via a read-only apt simulation,
reboot-required state and apt list freshness, and POSTs them as JSON.

Server: stdlib-only Python + SQLite (system python3 >= 3.11). Token-bound
ingest API, login-protected dashboard with per-host status
(stale/reboot/update/ok) and history, admin CLI, systemd unit and installer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 10:15:06 -04:00