| 1 | /** AVAIL and INUSE are spares, idle or standing in for a failed disk. */ |
| 2 | export type VdevState = "ONLINE" | "DEGRADED" | "FAULTED" | "OFFLINE" | "UNAVAIL" | "REMOVED" | "AVAIL" | "INUSE"; |
| 3 | |
| 4 | export interface Disk { |
| 5 | /** /dev/disk/by-id name, as zpool status prints it. */ |
| 6 | name: string; |
| 7 | state: VdevState; |
| 8 | read: number; |
| 9 | write: number; |
| 10 | checksum: number; |
| 11 | smart: { |
| 12 | model: string; |
| 13 | serial: string; |
| 14 | capacity: number; |
| 15 | passed: boolean; |
| 16 | temperature: number; |
| 17 | /** Lowest and highest over the last 24 hours, from the metrics store. */ |
| 18 | temperatureRange: [low: number, high: number]; |
| 19 | powerOnHours: number; |
| 20 | /** ATA attributes 5 and 197; NVMe drives have neither. */ |
| 21 | reallocated: number | null; |
| 22 | pending: number | null; |
| 23 | } | null; |
| 24 | } |
| 25 | |
| 26 | /** A top-level vdev such as raidz2-0, or a support class (logs, cache, spares) listed the same way. */ |
| 27 | export interface Vdev { |
| 28 | name: string; |
| 29 | state: VdevState; |
| 30 | disks: Disk[]; |
| 31 | } |
| 32 | |
| 33 | export interface Pool { |
| 34 | name: string; |
| 35 | state: VdevState; |
| 36 | /** Raw bytes including parity, as zpool list reports them. */ |
| 37 | size: number; |
| 38 | allocated: number; |
| 39 | free: number; |
| 40 | fragmentation: number; |
| 41 | scan: { |
| 42 | kind: "scrub" | "resilver"; |
| 43 | state: "scanning" | "finished" | "canceled"; |
| 44 | start: number; |
| 45 | end: number | null; |
| 46 | examined: number; |
| 47 | total: number; |
| 48 | repaired: number; |
| 49 | errors: number; |
| 50 | } | null; |
| 51 | vdevs: Vdev[]; |
| 52 | errors: string; |
| 53 | } |
| 54 | |
| 55 | /** Named after the zfs properties they come from. */ |
| 56 | export interface Dataset { |
| 57 | name: string; |
| 58 | used: number; |
| 59 | usedbydataset: number; |
| 60 | usedbysnapshots: number; |
| 61 | referenced: number; |
| 62 | available: number; |
| 63 | compressratio: number; |
| 64 | /** Bytes before compression. */ |
| 65 | logicalused: number; |
| 66 | /** e.g. "lz4" or "zstd". */ |
| 67 | compression: string; |
| 68 | recordsize: number; |
| 69 | /** Null for `none` and unmounted datasets. */ |
| 70 | mountpoint: string | null; |
| 71 | /** 0 means no quota. */ |
| 72 | quota: number; |
| 73 | /** The snapshot a clone was made from. */ |
| 74 | origin: string | null; |
| 75 | } |
| 76 | |
| 77 | export interface Snapshot { |
| 78 | /** The part after @. */ |
| 79 | name: string; |
| 80 | creation: number; |
| 81 | /** Space only this snapshot holds. */ |
| 82 | used: number; |
| 83 | referenced: number; |
| 84 | clones: string[]; |
| 85 | } |