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>
This commit is contained in:
patrickandClaude Opus 5.5 committed 2026-10-31 19:50:44 -04:00
1 parent 5a11d31e66
commit bc46c55298
15 files changed
+348 -7

No files matched your search

+28 -2
View File
@@ -6,7 +6,7 @@
# rules can change without redeploying agents.
set -euo pipefail
AGENT_VERSION=0.6.0
AGENT_VERSION=0.7.0
# Prefix for every file the agent reads. Only the test suite sets this.
ROOT=${KERNELWATCH_ROOT:-}
@@ -261,6 +261,25 @@ unfinished_packages() {
sort -u || true
}
# Ubuntu Pro state from the pro client's status cache, which it keeps
# world-readable (the token lives in private/ next to it). Prints "ATTACHED ESM"
# (e.g. "true enabled", "false -"); nothing if there's no file or it can't be
# read, as on Debian. Past standard support, only esm-infra keeps main patched.
PRO_STATUS_FILE=$ROOT/var/lib/ubuntu-advantage/status.json
ubuntu_pro() {
[[ -r $PRO_STATUS_FILE ]] || return 0
command -v python3 >/dev/null || return 0
python3 -I -c '
import json, re, sys
d = json.load(open(sys.argv[1]))
attached = d.get("attached") is True
esm = next((s.get("status") for s in d.get("services") or []
if isinstance(s, dict) and s.get("name") == "esm-infra"), None)
esm = esm if attached and isinstance(esm, str) and re.fullmatch(r"[a-z/-]{1,20}", esm) else "-"
print("true" if attached else "false", esm)
' "$PRO_STATUS_FILE" 2>/dev/null || true
}
uptime_seconds() {
local up _
[[ -r $ROOT/proc/uptime ]] || return 0
@@ -270,7 +289,7 @@ uptime_seconds() {
build_report() {
local running newest kernels sim inst sim_err rc apt_ok=1 apt_err='' reboot_file=0 reboot_pkgs=
local boot_size='' boot_free=''
local boot_size='' boot_free='' pro_attached='' pro_esm=''
running=$(uname -r)
kernels=$(installed_kernels)
@@ -295,6 +314,8 @@ build_report() {
fi
read -r boot_size boot_free <<<"$(boot_space)" || true
read -r pro_attached pro_esm <<<"$(ubuntu_pro)" || true
[[ $pro_esm == - ]] && pro_esm=
printf '{'
printf '"agent_version":%s,' "$(json_str "$AGENT_VERSION")"
@@ -335,6 +356,11 @@ build_report() {
printf '"boot_size_kb":%s,' "$(json_int "$boot_size")"
printf '"boot_free_kb":%s,' "$(json_int "$boot_free")"
printf '"dpkg_unfinished_packages":%s,' "$(unfinished_packages | json_str_array)"
case $pro_attached in
true | false) printf '"ubuntu_pro_attached":%s,' "$pro_attached" ;;
*) printf '"ubuntu_pro_attached":null,' ;;
esac
printf '"ubuntu_esm_infra":%s,' "$(json_str_or_null "$pro_esm")"
printf '"apt_lists_age_seconds":%s,' "$(json_int "$(apt_lists_age)")"
printf '"uptime_seconds":%s' "$(json_int "$(uptime_seconds)")"
printf '}\n'