diff --git a/web/src/Top.tsx b/web/src/Top.tsx index eabe246..c077bf8 100644 --- a/web/src/Top.tsx +++ b/web/src/Top.tsx @@ -251,6 +251,19 @@ export default function Top() { // the process table, and the CPU model, come from the same place the Processes page reads const [pt, setPt] = useState(null) const [pickedIf, setPickedIf] = useState(null) // which NIC the net box draws + // Which pool each drive belongs to, asked once: a drive in a ZFS pool has no filesystem of + // its own, and "nothing is on it" would be a lie about eight drives holding a NAS. + const [pools, setPools] = useState>({}) + useEffect(() => { + let live = true + api.storage().then((r) => { + if (!live) return + const m: Record = {} + for (const d of r.devices) for (const part of d.parts) if (part.fstype === 'zfs_member' && part.label) m[d.name] = part.label + setPools(m) + }).catch(() => { /* the rows simply say less */ }) + return () => { live = false } + }, []) const [err, setErr] = useState('') useEffect(() => { let stop = false @@ -389,7 +402,7 @@ export default function Top() { // shows what is true of the hardware — how busy it is, and how hot. const on = fs.filter((f) => f.disk === d.name) const used = on.reduce((a, f) => a + f.used, 0) - return f.mount)} /> + return f.mount)} pool={pools[d.name]} /> })} {(s?.disks ?? []).length === 0 &&
no drives reported
} @@ -485,7 +498,7 @@ const Rows = memo(function Rows({ procs, sel, onSel, curves, empty }: { procs: P // One physical drive. `used` is the bytes of the filesystems on it, left out when none can // be attributed to it — a pool member's share of a pool is not a number worth inventing. -function Disk({ name, note, size, used, io, temp, mounts }: { name: string; note?: string; size: number; used?: number; io?: number; temp?: number; mounts?: string[] }) { +function Disk({ name, note, size, used, io, temp, mounts, pool }: { name: string; note?: string; size: number; used?: number; io?: number; temp?: number; mounts?: string[]; pool?: string }) { const upct = used !== undefined && size > 0 ? (used / size) * 100 : 0 return (
@@ -504,7 +517,7 @@ function Disk({ name, note, size, used, io, temp, mounts }: { name: string; note {mounts && mounts.length > 0 &&
{mounts.join(' ')}
} ) : ( -
no filesystem of this machine is on it
+
{pool ? `member of ZFS pool ${pool}` : 'nothing mounted from it'}
)}
)