{"record":{"id":"472dd6a489e3a241","repo":"ClementTsang/bottom","slug":"unable-to-open-zfs-proc-directory","errorCode":null,"errorMessage":"Unable to open zfs proc directory","messagePattern":"Unable to open zfs proc directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/collection/disks/zfs_io_counters.rs","lineNumber":145,"sourceCode":"                                });\n\n                                let counter = IoCounters::new(name.to_owned(), read, write);\n                                Some(counter)\n                            } else {\n                                None\n                            }\n                        })\n                        .collect();\n                    Some(io_counters)\n                } else {\n                    None\n                }\n            })\n            .flatten()\n            .collect(); // combine io-counters\n        Ok(results)\n    } else {\n        Err(anyhow::anyhow!(\"Unable to open zfs proc directory\"))\n    }\n}\n","sourceCodeStart":127,"sourceCodeEnd":148,"githubUrl":"https://github.com/ClementTsang/bottom/blob/b77d3175028849824e987c35177e8f61450d72e7/src/collection/disks/zfs_io_counters.rs#L127-L148","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check that `/proc/spl/kstat/zfs` exists (`ls /proc/spl/kstat/zfs`) before calling; if not, treat ZFS metrics as unavailable","Load ZFS (`modprobe zfs`) or install OpenZFS if ZFS support is expected","Only call `zfs_io_stats()` on hosts known to run ZFS pools; otherwise fall back to generic disk stats","If running in a container, verify /proc is not masked and the ZFS module is loaded on the host"],"exampleFix":"// before\nlet zfs_stats = zfs_io_stats()?;\n// after\nlet zfs_stats = if std::path::Path::new(\"/proc/spl/kstat/zfs\").is_dir() {\n    zfs_io_stats().unwrap_or_default()\n} else {\n    Vec::new() // no ZFS on this host\n};","handlingStrategy":"fallback","validationCode":"if !std::path::Path::new(\"/proc/spl/kstat/zfs\").is_dir() {\n    eprintln!(\"ZFS kstats unavailable on this host\");\n    return Ok(Vec::new()); // or fall back to generic disk stats\n}\nlet stats = zfs_io_stats()?;","typeGuard":"fn zfs_available() -> bool {\n    std::path::Path::new(\"/proc/spl/kstat/zfs\").is_dir()\n}","tryCatchPattern":"match zfs_io_stats() {\n    Ok(stats) => handle(stats),\n    Err(e) if e.to_string().contains(\"Unable to open zfs proc\") => {\n        eprintln!(\"no ZFS on this host; using empty stats\");\n        handle(Vec::new())\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Gate ZFS collection on /proc/spl/kstat/zfs existing","Install OpenZFS or run `modprobe zfs` on hosts expected to have ZFS pools","In containers, verify the host's ZFS module is loaded and /proc is not masked","Make ZFS metrics optional in your pipeline; treat their absence as normal on non-ZFS hosts"],"tags":["linux","zfs","procfs","disks","io-counters"],"backgroundTag":"directory-not-found","analyzedSha":"b77d3175028849824e987c35177e8f61450d72e7","analyzedAt":"2026-09-07T14:53:21.246Z","contentChangedAt":"2026-09-07T14:53:21.246Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}