ClementTsang/bottom · error

Unable to open zfs proc directory

Error message

Unable to open zfs proc directory

What it means

The Linux-only public `zfs_io_stats()` reads ZFS zpool/dataset I/O counters from `/proc/spl/kstat/zfs/*/objset-*`. If the base directory `/proc/spl/kstat/zfs` cannot be opened with `read_dir`, it bails with 'Unable to open zfs proc directory' — meaning the kernel does not expose the ZFS kstat interface, i.e. ZFS is not loaded/installed on this machine.

Solutions

  1. Check that `/proc/spl/kstat/zfs` exists (`ls /proc/spl/kstat/zfs`) before calling; if not, treat ZFS metrics as unavailable
  2. Load ZFS (`modprobe zfs`) or install OpenZFS if ZFS support is expected
  3. Only call `zfs_io_stats()` on hosts known to run ZFS pools; otherwise fall back to generic disk stats
  4. If running in a container, verify /proc is not masked and the ZFS module is loaded on the host

Example fix

// before
let zfs_stats = zfs_io_stats()?;
// after
let zfs_stats = if std::path::Path::new("/proc/spl/kstat/zfs").is_dir() {
    zfs_io_stats().unwrap_or_default()
} else {
    Vec::new() // no ZFS on this host
};
Defensive patterns

Strategy: fallback

Validate before calling

if !std::path::Path::new("/proc/spl/kstat/zfs").is_dir() {
    eprintln!("ZFS kstats unavailable on this host");
    return Ok(Vec::new()); // or fall back to generic disk stats
}
let stats = zfs_io_stats()?;

Type guard

fn zfs_available() -> bool {
    std::path::Path::new("/proc/spl/kstat/zfs").is_dir()
}

Try / catch

match zfs_io_stats() {
    Ok(stats) => handle(stats),
    Err(e) if e.to_string().contains("Unable to open zfs proc") => {
        eprintln!("no ZFS on this host; using empty stats");
        handle(Vec::new())
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `zfs_io_stats()` on a Linux system without ZFS (no `/proc/spl/kstat/zfs`); ZFS module not loaded (`zfs` module unloaded or spl missing); kernel without ZFS support; procfs mounted elsewhere/restricted.

Common situations: Default distro kernels without OpenZFS; ZFS installed but module not yet loaded at boot; containers where /proc is masked; running the collector on non-ZFS cloud VMs.

Related errors


AI-assisted analysis of ClementTsang/bottom@b77d317502 (2026-09-07). Data as JSON: /api/errors/472dd6a489e3a241. Report an issue: GitHub.

Appendix: source

Thrown at src/collection/disks/zfs_io_counters.rs:145

                                });

                                let counter = IoCounters::new(name.to_owned(), read, write);
                                Some(counter)
                            } else {
                                None
                            }
                        })
                        .collect();
                    Some(io_counters)
                } else {
                    None
                }
            })
            .flatten()
            .collect(); // combine io-counters
        Ok(results)
    } else {
        Err(anyhow::anyhow!("Unable to open zfs proc directory"))
    }
}

View on GitHub (pinned to b77d317502)