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 (

Host health

{health.reportedAt && (
reported
)}
{failedUnits !== undefined && (
Services
{failedUnits.length === 0 ? ( none have failed ) : (
    {failedUnits.map((u) => (
  • failed {u.unit} {u.description && {u.description}}
  • ))}
)}
)} {hasSmart && (
Disks (SMART)
{smart!.map((d) => ( ))}
Disk Model Verdict Temperature Life used
{d.device} {d.model || "—"} {d.healthy === null ? ( — ) : d.healthy ? ( passes ) : ( failing )} {d.temperatureC === null ? "—" : `${Math.round(d.temperatureC)} °C`} {d.wearPercent === null ? "—" : `${Math.round(d.wearPercent)}%`}
)} {hasZfs && (
ZFS pools
{zfs!.map((p) => ( ))}
Pool State Used
{p.name} {p.health} {p.capacityPercent === null ? "—" : `${Math.round(p.capacityPercent)}%`}
)}
); }