Host health from the Linux agent, agent self-update, and disk forecast in /metrics

- Linux agent v4: failed systemd services, SMART disk health, ZFS pool state, pacman updates;
  SMART/ZFS and self-update run in the ExecStartPre=-+ step outside the sandbox
- Server: hosts' health stored (servers.host_health, migration 0029), alerts under a new
  "Failing services" kind plus disk/ZFS alerts, Host health card, Prometheus series
- Agent self-update (Linux v4, Windows v3): admin switch on the Servers page, checksum-verified
  download, atomic replace; GET /api/agent/report/update
- homelab_server_disk_days_to_full in /metrics
- Tests (server, real PowerShell against a fake server) and docs

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-18 00:54:24 +02:00
1 parent 540ab704b7
commit 5dc6cea69c
38 files changed
+3884 -73

No files matched your search

+121
View File
@@ -0,0 +1,121 @@
import type { HostHealth } from "../api/client";
import TimeAgo from "./TimeAgo";
/** The degraded states of a ZFS pool are all "not fine", but only ONLINE is quite fine. */
const poolFine = (health: string) => health.toUpperCase() === "ONLINE";
/**
* What the agent says about the machine itself: services that have failed, whether each disk's SMART check passes and how worn it is, and
* whether each ZFS pool is online. Each part appears only if the agent reported it (no smartctl or no ZFS on the host means no part),
* and the card is left out when it has nothing to say.
*/
export default function HostHealthCard({ health }: { health: HostHealth | null }) {
if (!health) return null;
const { failedUnits, smart, zfs } = health;
const hasSmart = !!smart && smart.length > 0;
const hasZfs = !!zfs && zfs.length > 0;
if (failedUnits === undefined && !hasSmart && !hasZfs) return null;
return (
<div className="card mb-3">
<div className="card-header">
<h3 className="card-title">Host health</h3>
{health.reportedAt && (
<div className="card-actions text-secondary small">
reported <TimeAgo value={health.reportedAt} />
</div>
)}
</div>
<div className="card-body">
{failedUnits !== undefined && (
<div className={hasSmart || hasZfs ? "mb-3" : ""}>
<div className="text-secondary small mb-1">Services</div>
{failedUnits.length === 0 ? (
<span className="badge bg-green-lt text-green">none have failed</span>
) : (
<ul className="list-unstyled mb-0">
{failedUnits.map((u) => (
<li key={u.unit}>
<span className="badge bg-red-lt text-red me-2">failed</span>
<code>{u.unit}</code>
{u.description && <span className="text-secondary small ms-2">{u.description}</span>}
</li>
))}
</ul>
)}
</div>
)}
{hasSmart && (
<div className={hasZfs ? "mb-3" : ""}>
<div className="text-secondary small mb-1">Disks (SMART)</div>
<div className="table-responsive">
<table className="table table-sm table-vcenter mb-0">
<thead>
<tr>
<th>Disk</th>
<th>Model</th>
<th>Verdict</th>
<th>Temperature</th>
<th>Life used</th>
</tr>
</thead>
<tbody>
{smart!.map((d) => (
<tr key={d.device}>
<td>
<code>{d.device}</code>
</td>
<td className="text-secondary">{d.model || "—"}</td>
<td>
{d.healthy === null ? (
<span className="text-secondary">—</span>
) : d.healthy ? (
<span className="badge bg-green-lt text-green">passes</span>
) : (
<span className="badge bg-red-lt text-red">failing</span>
)}
</td>
<td>{d.temperatureC === null ? "—" : `${Math.round(d.temperatureC)} °C`}</td>
<td>{d.wearPercent === null ? "—" : `${Math.round(d.wearPercent)}%`}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
)}
{hasZfs && (
<div>
<div className="text-secondary small mb-1">ZFS pools</div>
<div className="table-responsive">
<table className="table table-sm table-vcenter mb-0">
<thead>
<tr>
<th>Pool</th>
<th>State</th>
<th>Used</th>
</tr>
</thead>
<tbody>
{zfs!.map((p) => (
<tr key={p.name}>
<td>
<code>{p.name}</code>
</td>
<td>
<span className={`badge ${poolFine(p.health) ? "bg-green-lt text-green" : "bg-red-lt text-red"}`}>{p.health}</span>
</td>
<td>{p.capacityPercent === null ? "—" : `${Math.round(p.capacityPercent)}%`}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
)}
</div>
</div>
);
}
+2 -1
View File
@@ -10,7 +10,8 @@ import TimeAgo from "./TimeAgo";
export const CATEGORY_WORDS: Record<AlertCategory, string> = {
offline: "a server that stopped reporting",
disk: "a disk filling up",
disk: "a disk filling up or failing",
services: "a failed service",
backup: "a backup problem",
updates: "updates waiting",
expiry: "something expiring",