mirror of
https://github.com/henrygd/beszel.git
synced 2026-09-21 17:07:47 +02:00
fix(zfs): skip zpool list when /dev/zfs unavailable in Linux (#2325)
Co-authored-by: henrygd <hank@henrygd.me>
This commit is contained in:
@@ -13,7 +13,10 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
var procZfsPath = "/proc/spl/kstat/zfs"
|
||||
var (
|
||||
procZfsPath = "/proc/spl/kstat/zfs"
|
||||
devZfsPath = "/dev/zfs"
|
||||
)
|
||||
|
||||
func ARCSize() (uint64, error) {
|
||||
file, err := os.Open(filepath.Join(procZfsPath, "arcstats"))
|
||||
@@ -40,6 +43,19 @@ func ARCSize() (uint64, error) {
|
||||
return 0, fmt.Errorf("size field not found in arcstats")
|
||||
}
|
||||
|
||||
// checkZfsDevice lets containers without /dev/zfs fail fast instead of
|
||||
// waiting for ZFS utility commands to time out.
|
||||
func checkZfsDevice() error {
|
||||
_, err := os.Stat(devZfsPath)
|
||||
if err != nil {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
return ErrNoZfs
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// PoolKernelStats reads pool state and cumulative I/O counters directly from
|
||||
// procfs. These kstats are the same interfaces used by node_exporter's Linux
|
||||
// ZFS collector and avoid keeping a `zpool iostat` subprocess alive.
|
||||
|
||||
Reference in New Issue
Block a user