LinuxCommandLibrary

kstats

Display kernel statistics

SYNOPSIS

kstats type [name] [instance] [name] ...

PARAMETERS

type
    The mandatory type of kstat to query, e.g., cpu_info, arcstats, zpool_stats. This corresponds to the module or class of statistics. On Linux, common types like arcstats and zpool_stats are relevant for ZFS.

[name]
    Optional. Specifies the name of the kstat. Kstats are often organized hierarchically by type, name, and instance.

[instance]
    Optional. Specifies the instance number of the kstat, especially when multiple instances of a similar type exist (e.g., multiple CPUs, multiple ZFS pools).

DESCRIPTION

The kstats command is a utility provided by the libkstat-dev package on Linux, designed to query and display kernel statistics (kstats) that conform to the Solaris/illumos kstat framework. While kstat is native to Solaris and illumos operating systems, this command finds its primary utility on Linux systems primarily through the ZFS on Linux implementation, where ZFS modules export various performance and operational metrics via a compatible kstat interface. It allows users to inspect low-level kernel counters, timers, and data structures related to ZFS pools, datasets, and other ZFS components, providing insights into storage performance, cache hits/misses, and other ZFS-specific operational details. Without ZFS or other kstat-exposing modules loaded, kstats may report lookup errors as the underlying kstat data is not available.

CAVEATS

Linux Specificity: The kstats command is not a standard, general-purpose Linux kernel statistics tool. It relies on the libkstat library, which provides a compatibility layer for the Solaris/illumos kstat framework.
Module Dependency: Its utility on Linux is largely dependent on specific kernel modules, most notably ZFS on Linux, which exposes its statistics via a kstat-compatible interface. Without ZFS or other kstat-exposing modules loaded, the command will typically fail to find data (e.g., "failed to lookup kstat module '...'" or "No such file or directory").
Limited Scope: It does not provide general Linux performance metrics (like CPU usage, memory, disk I/O for non-ZFS filesystems) that tools like top, mpstat, iostat, or perf do.
No Man Page: As of current distributions, a dedicated man kstats page is often unavailable, making its usage discovery reliant on trial and error or external documentation.

TYPICAL ZFS USAGE

On Linux, common type values for kstats when ZFS is loaded include arcstats (for ZFS ARC cache statistics) and zpool_stats (for overall ZFS pool statistics). For example, to view ARC statistics: kstats arcstats.
To see stats for a specific ZFS pool named 'mydata': kstats zpool_stats mydata. The output provides various counters and values relevant to ZFS performance and health.

HISTORY

The kstat framework originated in Solaris and illumos operating systems as a mechanism for kernel modules to export performance, configuration, and debugging statistics. The libkstat library and associated utilities like kstats were developed to provide a userland interface to these kernel statistics. When ZFS was ported to Linux (ZFS on Linux project), the need arose to access its internal statistics. To maintain compatibility with Solaris-based tooling and leverage the existing kstat infrastructure, the ZFS on Linux module was designed to export its metrics through a kstat-compatible interface. The kstats command on Linux is part of the libkstat-dev package, providing a bridge to read these ZFS-exported kernel statistics, thus bringing a piece of the Solaris diagnostic toolkit to Linux environments where ZFS is used.

SEE ALSO

zpool(8), zfs(8), iostat(1), dstat(1), mpstat(1), perf(1)

Copied to clipboard