collector: data delle liste apt e nomi dei pacchetti in updates
Un totale a 0 non era verificabile: il 28/10 un dist-upgrade automatico (bind9-*) aveva svuotato la lista mentre Webmin mostrava ancora 3 update. Ora lo snapshot porta lists_updated_at e l'elenco dei pacchetti, cosi' un 'nessun aggiornamento' si puo' datare.
This commit is contained in:
1 parent
edc8a8b4ed
commit
a8486a4115
2 files changed
+22
-2
No files matched your search
+2
-1
@@ -60,7 +60,8 @@ Nessun log HTTP: il token non finisce su disco. Il server non ha altre rotte.
|
|||||||
"exit_code": 0, "age_hours": 41.5 },
|
"exit_code": 0, "age_hours": 41.5 },
|
||||||
"services": { "failed": [ { "unit": "…", "description": "…" } ] },
|
"services": { "failed": [ { "unit": "…", "description": "…" } ] },
|
||||||
"access": { "ssh_failed_24h": 0 },
|
"access": { "ssh_failed_24h": 0 },
|
||||||
"updates": { "total": 0, "security": 0 },
|
"updates": { "total": 0, "security": 0, "packages": [],
|
||||||
|
"lists_updated_at": "2026-10-28T07:47:36+00:00" },
|
||||||
"net": { "interfaces": ["wg0"], "up": true },
|
"net": { "interfaces": ["wg0"], "up": true },
|
||||||
"errors": [ "collector: motivo" ]
|
"errors": [ "collector: motivo" ]
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-1
@@ -214,7 +214,26 @@ def updates_info() -> dict:
|
|||||||
raw = run(["apt", "list", "--upgradable"], timeout=20)
|
raw = run(["apt", "list", "--upgradable"], timeout=20)
|
||||||
lines = [l for l in raw.splitlines() if "upgradable" in l and "/" in l]
|
lines = [l for l in raw.splitlines() if "upgradable" in l and "/" in l]
|
||||||
security = sum(1 for l in lines if "-security" in l or "Security" in l)
|
security = sum(1 for l in lines if "-security" in l or "Security" in l)
|
||||||
return {"total": len(lines), "security": security}
|
packages = [l.split("/")[0].strip() for l in lines][:20]
|
||||||
|
|
||||||
|
# Quando sono state aggiornate le liste apt. Senza questo dato un "0" non e'
|
||||||
|
# verificabile: un dist-upgrade automatico puo' aver appena svuotato la
|
||||||
|
# lista e sembra che il collector non veda nulla (successo davvero il
|
||||||
|
# 2026-10-28 con bind9-*: Webmin mostrava 3 update, lo snapshot 0).
|
||||||
|
lists_at = None
|
||||||
|
try:
|
||||||
|
stamps = [p.stat().st_mtime for p in Path("/var/lib/apt/lists").glob("*InRelease")]
|
||||||
|
if stamps:
|
||||||
|
lists_at = iso(max(stamps))
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return {
|
||||||
|
"total": len(lines),
|
||||||
|
"security": security,
|
||||||
|
"packages": packages,
|
||||||
|
"lists_updated_at": lists_at,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def vpn_info() -> dict:
|
def vpn_info() -> dict:
|
||||||
|
|||||||
Reference in new issue
Block a user