LinuxCommandLibrary

iostat

Report CPU and I/O statistics

TLDR

Display a report of CPU and disk statistics since system startup

$ iostat
copy

Display a report of CPU and disk statistics with units converted to megabytes
$ iostat -m
copy

Display CPU statistics
$ iostat [[-c|--compact]]
copy

Display disk statistics with disk names (including LVM)
$ iostat -N
copy

Display extended disk statistics with disk names for device "sda"
$ iostat -xN [sda]
copy

Display incremental reports of CPU and disk statistics every 2 seconds
$ iostat [2]
copy

SYNOPSIS

iostat [ OPTIONS ] [ INTERVAL [ COUNT ] ]

PARAMETERS

-c
    Display the CPU utilization report.

-d
    Display the device utilization report.

-h
    Display statistics in a human-readable format (e.g., kB, MB, GB).

-k, -m, -g
    Display statistics in kilobytes, megabytes, or gigabytes per second, respectively.

-p [ { device [,...] | ALL } ]
    Display statistics for disks and partitions. Specify specific devices or 'ALL'.

-x
    Display extended statistics, including average queue length, service time, and I/O utilization.

-y
    Omit the first report, which covers the period since system boot.

-z
    Suppress lines for devices or CPU states with zero activity.

-t
    Print the time of each report.

-V
    Display version information.

INTERVAL
    Time in seconds between each successive report.

COUNT
    The number of reports to generate. If not specified with an INTERVAL, only one report is generated.

DESCRIPTION

iostat is a command-line utility used to monitor and report CPU utilization and I/O statistics for devices, partitions, and network filesystems (NFS). It is a fundamental tool for system administrators and performance analysts to diagnose performance bottlenecks related to disk I/O or CPU contention. Part of the sysstat package, iostat provides valuable insights into how much CPU time is spent on various tasks (user, system, idle, I/O wait) and the throughput, operations per second, and latency of storage devices. By observing metrics like reads/writes per second, kilobyte transfer rates, average queue lengths, and I/O utilization, users can identify devices that are heavily loaded or experiencing high latency, which might indicate a bottleneck in the storage subsystem. It helps in understanding the workload distribution across the system and optimizing resource allocation and capacity planning.

CAVEATS

iostat relies on data from the `/proc` and `/sys` filesystems, which provide kernel statistics. The first report, by default, provides averages since system boot, which may not reflect current activity; use the `-y` option to skip it. Interpreting the output requires a solid understanding of disk I/O metrics and their implications for performance. For example, high `%util` combined with high `await` times typically indicates a disk bottleneck. While useful for ad-hoc snapshots, for continuous, long-term monitoring or historical trending, `sar` (also part of `sysstat`) or other dedicated monitoring systems are generally more appropriate.

KEY METRICS EXPLAINED

iostat reports various metrics crucial for performance analysis. For CPU, these include %user (percentage of CPU utilization in user-level applications), %system (percentage of CPU utilization in the kernel), %iowait (percentage of time CPU was idle with pending disk I/O requests), and %idle (percentage of time CPU was idle with no pending disk I/O requests).

For devices, common metrics include r/s (reads per second), w/s (writes per second), rkB/s (kilobytes read per second), wkB/s (kilobytes written per second), await (the average time, in milliseconds, for I/O requests issued to the device to be served), and %util (percentage of time during which I/O requests were issued to the device). Understanding these metrics is vital for diagnosing performance issues and identifying bottlenecks.

HISTORY

iostat is a long-standing utility, originating from the Unix world and later adapted for Linux. It is a core component of the sysstat package, which has been actively maintained for decades by Sebastien Godard. The sysstat project aims to provide comprehensive system monitoring tools for Linux. Over its history, iostat has evolved to include more detailed metrics and options to better reflect modern storage technologies and diverse workloads, enhancing its utility for performance analysis and troubleshooting in complex Linux environments.

SEE ALSO

sar(1), vmstat(8), mpstat(1), top(1), dstat(1)

Copied to clipboard