Skip to main content

collect_zfs_spaces

Function collect_zfs_spaces 

Source
fn collect_zfs_spaces(timeout: Duration) -> Vec<(String, DiskMountMetrics)>
Expand description

Collect space stats for every imported ZFS pool via zpool list -Hp.

ZFS statvfs is unsuitable for pool-level capacity: the kernel sets f_blocks = (pool_avail + dataset.referenced_bytes) >> SPA_MINBLOCKSHIFT, i.e. only the REFER column (space at this dataset level, not recursive), not the pool total. For a pool with many child datasets this gives a heavily under-counted figure. zpool list is the only authoritative source for pool capacity, used, and free.

Mount-point information is looked up from /proc/mounts as a best-effort annotation; the dataset with the fewest path components per pool is preferred.