feat(host_agent): each drive's health, read with smartctl, alertable (#5789)
The root helper gains one read-only action, `drives`: it finds the drives itself (smartctl --scan-open), reads each as JSON, and writes a summary the agent carries on every sample (agent 1.20.0). Steward judges the figures in drives.py (failing / worn / watch / ok / no SMART / unreadable), records them per drive and as host roll-ups for covering rules, keeps the newest report on the registration and lists it on the host page. install-deps.sh installs smartmontools with apt, dnf, yum, zypper, pacman or apk, run by install.sh and every agent playbook; one it can't install is reported, never fatal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -385,17 +385,19 @@ async def resources_for(db, source_module: str) -> list[str]:
|
||||
# A host's parts, by the shape of the name after "<host>:" (#5475): the order
|
||||
# and heading each kind takes in the rule form's Part picker.
|
||||
PART_KINDS = (("mount", "Mounts"), ("core", "CPU cores"), ("disk", "Disks"),
|
||||
("net", "Interfaces"), ("temp", "Temperatures"), ("other", "Other"))
|
||||
("drive", "Drive health"), ("net", "Interfaces"), ("temp", "Temperatures"),
|
||||
("other", "Other"))
|
||||
|
||||
|
||||
def part_kind(part: str) -> tuple[str, str]:
|
||||
"""(kind, label) for a host part: "/var" is a mount, "core3" a core,
|
||||
"diskio:sda" a disk, "net:eth0" an interface, "temp:Core 0" a sensor."""
|
||||
"diskio:sda" a disk, "drive:sda" its health (#5789), "net:eth0" an
|
||||
interface, "temp:Core 0" a sensor."""
|
||||
if part.startswith("/"):
|
||||
return "mount", part
|
||||
if part.startswith("core") and part[4:].isdigit():
|
||||
return "core", f"core {part[4:]}"
|
||||
for prefix, kind in (("diskio:", "disk"), ("net:", "net"), ("temp:", "temp")):
|
||||
for prefix, kind in (("diskio:", "disk"), ("drive:", "drive"), ("net:", "net"), ("temp:", "temp")):
|
||||
if part.startswith(prefix):
|
||||
return kind, part[len(prefix):]
|
||||
return "other", part
|
||||
|
||||
Reference in New Issue
Block a user