zfs

package
v0.21.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package zfs provides functions to read ZFS statistics.

Package zfs provides functions to read ZFS statistics.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoZfs = errors.New("zfs utilities unavailable")

ErrNoZfs is returned when the ZFS utilities or kernel interfaces are unavailable.

Functions

func ARCSize

func ARCSize() (uint64, error)

Types

type Dataset added in v0.19.0

type Dataset struct {
	Name       string
	Used       uint64
	Avail      uint64
	Mountpoint string
}

Dataset is a single ZFS dataset with usage information.

func Datasets added in v0.19.0

func Datasets() ([]Dataset, error)

Datasets returns all datasets on the system with usage and mountpoint information using `zfs list` (recursive by default).

type PoolIoStats added in v0.19.0

type PoolIoStats struct {
	NRead  uint64
	NWrite uint64
}

PoolIoStats holds calculated per-second I/O rates for a pool.

type PoolKernelStat added in v0.19.0

type PoolKernelStat struct {
	Name   string
	Health string
	NRead  uint64
	NWrite uint64
}

PoolKernelStat is the inexpensive pool telemetry exposed by the ZFS kernel. NRead and NWrite are cumulative byte counters since the pool was imported.

func PoolKernelStats added in v0.19.0

func PoolKernelStats() ([]PoolKernelStat, error)

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.

type PoolStat added in v0.19.0

type PoolStat struct {
	DisplayName string // optional friendly name; Name remains the stable key
	MountID     string // Btrfs filesystem identity, empty for other backends
	IODevice    string // sole Btrfs member device, if known
	Raw         bool   // physical accounting rather than usable filesystem space
	Name        string
	Size        uint64 // total capacity in bytes
	Alloc       uint64 // allocated bytes
	Free        uint64 // free bytes
	Health      string // ONLINE, DEGRADED, FAULTED, ...
}

PoolStat is a snapshot of a ZFS pool's capacity and health.

func PoolStats added in v0.19.0

func PoolStats() ([]PoolStat, error)

PoolStats returns capacity and health for all pools on the system using `zpool list`, with capacity taken from each pool's root dataset where it can be read. Frequent health and I/O sampling uses PoolKernelStats instead.

type PoolStatus added in v0.19.0

type PoolStatus struct {
	Name   string
	State  string // ONLINE, DEGRADED, FAULTED, ...
	Status string // status: advisory message, when the pool carries one
	Scrub  ScrubStatus
	Vdevs  []VdevStatus
}

PoolStatus holds parsed `zpool status` information for one pool.

func PoolStatuses added in v0.19.0

func PoolStatuses() ([]PoolStatus, error)

PoolStatuses runs `zpool status` and parses per-pool state, scrub, and vdev information. The human-readable format has been stable across OpenZFS releases; rows are matched by their tabular shape rather than position.

type ScrubStatus added in v0.19.0

type ScrubStatus struct {
	State    string // NONE, SCANNING, FINISHED, CANCELED
	Progress string // e.g. "10.00%" while scanning
	Errors   uint64
}

ScrubStatus holds the scrub (or resilver) status parsed from the scan line.

type VdevStatus added in v0.19.0

type VdevStatus struct {
	Name         string
	State        string
	ReadErrs     uint64
	WriteErrs    uint64
	ChecksumErrs uint64
}

VdevStatus is a single vdev row (mirror, raidz, or leaf disk).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址