Home > Package & System Management > iostat

iostat: Report CPU utilization and I/O statistics

iostat is a command that reports CPU utilization and device (disk, partition) input/output statistics in real-time or at specified intervals. It is useful for diagnosing system performance bottlenecks and resolving I/O-related issues.

Overview

iostat provides statistics for CPU, disks, and network file systems (NFS) to help understand the overall performance status of the system and diagnose I/O-related problems. It is an essential tool for identifying bottlenecks, especially in systems with high disk I/O load.

Key Features

  • CPU utilization statistics (user, nice, system, idle, iowait, etc.)
  • Per-device (disk, partition) read/write requests per second and data transfer rates
  • Average service time, queue length, and I/O wait times per device
  • Periodic reporting of statistics at specified intervals
  • Support for various output formats and units

Key Options

The iostat command allows fine-grained control over the type of statistics reported, their format, and the reporting interval through various options.

Selecting Statistics Type

Output Format and Units

Generated command:

Try combining the commands.

Description:

`iostat` Executes the command.

Combine the above options to virtually execute commands with AI.

Usage Examples

Various examples of using the iostat command to check system CPU and disk I/O statistics.

Basic CPU and Disk I/O Statistics

iostat

Outputs CPU utilization and basic I/O statistics for all devices once.

Repeat 3 times with a 5-second interval

iostat 5 3

Outputs CPU and disk I/O statistics a total of 3 times, every 5 seconds.

View CPU Statistics Only

iostat -c

Displays only CPU utilization statistics.

View Extended Disk I/O Statistics

iostat -x

Outputs disk I/O statistics in an extended format, providing more detailed information.

View Extended I/O Statistics for a Specific Disk

iostat -x sda

Outputs extended I/O statistics for a specific disk (e.g., sda).

View Disk I/O Statistics in Human-Readable Units

iostat -h

Displays disk I/O statistics with data transfer amounts in human-readable units like K, M, G.

Repeat Disk Statistics Every 2 Seconds with Timestamp

iostat -d -t 2

Continuously outputs disk I/O statistics every 2 seconds, with a timestamp prepended to each report.

Installation

iostat is part of the `sysstat` package. It may not be installed by default on most Linux distributions. If needed, you can install it using the following commands:

Debian/Ubuntu

sudo apt update
sudo apt install sysstat

Install using the APT package manager.

CentOS/RHEL/Fedora

sudo yum install sysstat
# or
sudo dnf install sysstat

Install using the YUM or DNF package manager.

Arch Linux

sudo pacman -S sysstat

Install using the Pacman package manager.

Tips & Notes

Useful tips and points to consider when analyzing system performance using iostat.

Output Interpretation Guide

Brief explanations of key metrics.

  • **%user, %system, %iowait, %idle (CPU)**: Represents CPU utilization. A high %iowait may indicate a disk I/O bottleneck.
  • **r/s, w/s (Device)**: Number of read/write requests per second. Higher values indicate more disk activity.
  • **rkB/s, wkB/s (Device)**: Data read/written per second (in KB). Represents the actual data transfer rate.
  • **await (Device)**: The average time (in milliseconds) an I/O request spends waiting in the queue and being processed by the disk. A high value indicates slow disk response times.
  • **%util (Device)**: Device utilization. A value close to 100% indicates that the device is operating at its maximum capacity and could be a source of bottlenecks.

Continuous Monitoring

While iostat provides a snapshot at a specific moment, using repetitive options like `iostat interval count` for long-term monitoring is more effective for tracking performance trends and diagnosing intermittent issues.

Use in Conjunction with Other Tools

Since iostat is specialized for disk I/O, it is recommended to use it in conjunction with other system monitoring tools such as `top`, `vmstat`, and `free` for a comprehensive analysis of overall system status, including CPU, memory, and network.


Same category commands