Posted on
Software

iotstat: Disk I/O stats by devices

Author
  • User
    Linux Bash
    Posts by this author
    Posts by this author

Monitoring Disk I/O with iotstat on Linux

If you're managing or debugging Linux servers, particularly in environments heavily reliant on disk operations like database servers or file servers, monitoring Disk Input/Output (I/O) stats is crucial. An effective tool to help you in this endeavor is iotstat. This utility can provide real-time detailed information about disk I/O by each device, aiding in performance tuning and troubleshooting.

In this blog post, I'll introduce you to iotstat, explain its benefits, and guide you through installation via different Linux package managers — namely, apt (for Debian-based distributions), dnf (for Fedora and other RHEL-based distributions), and zypper (for openSUSE/SUSE).

What Is iotstat?

iotstat is a command-line tool that measures and displays system input/output loading by device. It aggregates and reports statistics on how much data was read from or written to each device. This information is vital for identifying performance bottlenecks and understanding how well your storage subsystem is handling current workloads.

Key Features of iotstat

  • Real-time monitoring: Update the I/O stats in real-time, offering a near-current view of the disk activity.

  • Per-device metrics: Provides breakdowns by each individual device, making it easier to spot issues specific to a single disk or array.

  • Flexible output: Customizable output format to focus on the metrics that matter most to you.

Installation Instructions

The installation method for iotstat depends on your Linux distribution. Below, I provide steps for installing iotstat available in major Linux distributions' default repositories.

Debian/Ubuntu (using apt)

  1. First, update your package list to ensure you have the latest repository information:

    sudo apt update
    
  2. Install iotstat:

    sudo apt install iotstat
    

Fedora, CentOS, or RHEL (using dnf)

For Fedora and other distributions using the dnf package manager, follow these steps:

  1. Update your DNF package repository cache:

    sudo dnf makecache
    
  2. Install iotstat:

    sudo dnf install iotstat
    

openSUSE/SUSE (using zypper)

For those using openSUSE or SUSE Linux, here’s how to install iotstat using zypper:

  1. Refresh all repository indexes:

    sudo zypper refresh
    
  2. Install iotstat:

    sudo zypper install iotstat
    

Using iotstat

After installation, you can start using iotstat from the terminal. Running iotstat without any options will display the I/O stats snapshot. However, you can customise its output using various flags and parameters to suit your specific needs. Here are a few examples:

  • Monitor every 2 seconds:

    iotstat 2
    
  • Extended statistics:

    iotstat -x
    
  • Only display device sda:

    iotstat -p sda
    

Conclusion

iotstat is a powerful tool that should be part of any Linux system administrator's arsenal. By providing detailed and easily consumed I/O statistics, iotstat helps in pinpointing performance bottlenecks and ensures you can make informed decisions about resource management and problem resolution. With the straightforward installation and usage instructions, you should be well-equipped to start monitoring your disk I/O performance.

Happy monitoring!