iostat

systemLinux
The iostat command is one of the most frequently used commands in Linux/Unix-like operating systems. iostat Report CPU statistics and input/output statistics for devices and partitions

Quick Reference

Command Name:

iostat

Category:

system

Platform:

Linux

Basic Usage:

iostat [options] [arguments]

Common Use Cases

    Syntax

    iostat [options] [device...] [interval [count]]

    Options

    Option Description
    -c Display CPU utilization report
    -d Display device utilization report
    -h Display help message and exit
    -k Display statistics in kilobytes per second
    -m Display statistics in megabytes per second
    -N Display registered device mapper names for LVM volumes
    -p [device] Display statistics for block device and all its partitions
    -t Print the time for each report
    -V Display version information and exit
    -x Display extended statistics
    -y Omit first report with statistics since system boot
    -z Omit output for any devices with no activity
    --dec={0|1|2} Specify the number of decimal places in output
    --human Print sizes in human-readable format
    interval Reporting interval in seconds
    count Number of reports to generate

    Examples

    How to Use These Examples

    The examples below show common ways to use the iostat command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    iostat
    Display a single report of CPU and device utilization.
    iostat -d
    Display only the device utilization report.
    # Advanced Examples Advanced
    iostat -c Display only the CPU utilization report. iostat 2 5 Display five reports at two-second intervals. iostat -x sda Display extended statistics for device sda. iostat -m Display statistics in megabytes per second instead of blocks/s. iostat -d -p sda Display statistics for sda and all its partitions. iostat -N Display the registered device mapper names for LVM volumes. iostat -xtc 2 Display extended stats, including CPU, every 2 seconds until interrupted. iostat -d -k sda sdb 1 10 Display kilobytes per second stats for sda and sdb every second for 10 iterations.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    iostat is a powerful monitoring tool that reports CPU, device, and partition I/O statistics. It's part of the sysstat package and is essential for system administrators who need to analyze system performance, especially disk I/O patterns and bottlenecks. Key features of iostat: 1. CPU Statistics: iostat can report on CPU utilization, breaking it down into categories such as user time, system time, idle time, and I/O wait time. This helps identify if a system is CPU-bound or waiting on I/O operations. 2. Device I/O Metrics: The tool provides detailed statistics on disk devices and partitions, including reads/writes per second, transfer rates, and service times, allowing administrators to identify which devices are experiencing heavy I/O load. 3. Extended Statistics: With the -x option, iostat provides in-depth metrics such as average queue lengths, average wait times, and utilization percentages, which are crucial for detailed performance analysis. 4. Interval Reporting: iostat can report statistics at specified intervals, making it suitable for real-time monitoring and for capturing trends over time. This is particularly useful when troubleshooting intermittent performance issues. 5. Partition-Specific Monitoring: Using the -p option, administrators can focus on specific partitions, helping to pinpoint which file systems are experiencing high I/O activity. 6. Multiple Output Formats: iostat can display statistics in different units (blocks, kilobytes, or megabytes per second), making it easier to interpret the data in a preferred format. 7. LVM Support: With the -N option, it can display registered device mapper names for Logical Volume Manager (LVM) volumes, which is useful in environments using LVM for storage management. Common use cases for iostat include: - Identifying disk I/O bottlenecks in a system - Monitoring the impact of application workloads on disk performance - Capacity planning for storage systems - Troubleshooting performance issues related to disk I/O - Baselining system performance for future comparison - Validating the effectiveness of storage optimizations The output of iostat is particularly valuable when analyzed alongside other system metrics from tools like vmstat, mpstat, and top to get a comprehensive view of system performance. By regularly monitoring these statistics, system administrators can proactively identify potential issues before they impact users or services.

    Related Commands

    These commands are frequently used alongside iostat or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the iostat command works in different scenarios.

    $ iostat
    View All Commands