System administrators often need to monitor disk IO performance in Linux to ensure that their systems are running properly. In this article, we will learn how to monitor disk IO performance in Linux.
How to Monitor Disk IO Performance in Linux
Here are the steps to monitor IO performance in Linux. Generally, the top command is most commonly used command to check server performance.
In its output, check the wa column to see if there are high I/O operations on any storage drives such as hard disks, SSDs and disk partitions. If there are many IO operations on your disk, then your system will be slow even if the CPU and memory usage is less. Sometimes the IO operations might even be fluctuating, causing performance issues.
In such cases, you can use iotop and iostat commands.
1. Using Iotop
Iotop is similar to top command as it displays real-time activity but it focuses more on IO operations on your disks and partitions. It keeps track of IO operations from kernel and displays current IO usage through processes and threads on the system. It also displays the percentage of time spent in waiting, swapping & performing IO operation.
Its main output parameters are Total DISK READ and Total DISK WRITE that represent total read & write bandwidth between processes & threads, and kernel devices. Actual DISK READ and DISK WRITE represent values for actual read & write bandwidth between processes & threads, and kernel devices.
Here is the command to install iotop.
# Fedora / CentOS / RHEL systems $ sudo dnf install iotop # Debian / Ubuntu systems $ sudo apt install iotop
Once it is installed, you can easily call iotop command to get IO stats.
If you only want to check actual processes that are currently using IO operations, use -o or –only command.
$ iotop -o
2. Using iostat
iostat is used to report server statistics as well as IO stats. It is used to monitor system load, amount of time the devices are active, their average transfer rates. It generates two types of reports – CPU utilization report and device utilization report.
Here is the command to install iostat command.
# Fedora / RHEL / CentOS $ sudo dnf install sysstat OR $ sudo yum install sysstat # Debian / Ubuntu $ sudo apt install sysstat
Once it is installed, you can measure IO performance with the following command.
The above command will display CPU as well as device statistics. If you only want to view device-related information, use -d option.
$ iostat -d
If you want to see IO statistics for IO devices and their partitions, use -p option.
$ iostat -p
If you want to see detailed IO statistics of all devices, use -x option.
$ iostat -x
If you want to view IO statistic of specific device you can specify it after -d option.
$ iostat -d [Device_Name]
Here is an example.
$ iostat -p /dev/sda1
Similarly, if you want to view IO statistic of specific partition, mention device name after -p option.
By default, all the numbers in iostat command’s output are in kB. If you want to view the same information in MB, you can use -m option.
In this article, we have seen a couple of useful tools iotop and iostat to view system IO statistics. You can use them as per your requirement.