3 Best Tools to Monitor Disk I/O Performance in Linux
Brief: In this guide, we will discuss the best tools for monitoring and debugging disk I/O activity (performance) on Linux servers.
A key performance metric to monitor on a Linux server is disk I/O (input/output) activity, which can significantly impact several aspects of a Linux server, particularly the speed of saving to or retrieval from disk, of files or data (especially on database servers). This has a ripple effect on the performance of applications and services.
1. iostat – Shows Device Input and Output Statistics
iosat is one of the many terminal-based system monitoring utilities in the sysstat package, which is a widely used utility designed for reporting CPU statistics and I/O statistics for block devices and partitions.
To use iostat on your Linux server, you need to install the sysstat package on your Linux system by running the applicable command for your Linux distribution.
sudo apt install sysstat [On Debian, Ubuntu and Mint] sudo yum install sysstat [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux] sudo emerge -a app-admin/sysstat [On Gentoo Linux] sudo apk add sysstat [On Alpine Linux] sudo pacman -S sysstat [On Arch Linux] sudo zypper install sysstat [On OpenSUSE]
To show a simple device utilization report, run iostat with the -d
command line option. Usually, the first report provides statistics about the time since the system startup (boot time), and each subsequent report is concerned with the time since the previous report.
Use the -x
for an extended statistics report and the -t
flag to enable time for each report. Besides, If you wish to eliminate devices without any activity in the report output, add the -z
flag:
iostat -d -t OR iostat -d -x -t
To display statistics in kilobytes per second as opposed to blocks per second add the -k
flag, or use the -m
flag to display stats in megabytes per second.
iostat -d -k OR iostat -d -m
iostat can also display continuous device reports at x second intervals. For example, the following command displays reports at two-second intervals:
iostat -d 2
Related to the previous command, you can display n number of reports at x second intervals. The following command will display 10 reports at two-second intervals.
iostat -d 2 10
Alternatively, you can save the report to a file for later analysis.
iostat -d 2 10 > disk_io_report.txt &
For more information about the report columns, read the iostat man page:
man iostat
2. sar – Show Linux System Activity
sar is another useful utility that ships with the sysstat package, intended to collect, report, or save system activity information. Before you can start using it, you need to set it up as follows.
First, enable it to collect data in the /etc/default/sysstat file.
vi /etc/default/sysstat
Look for the following line and change the value to “true” as shown.
ENABLED="true"
Next, you need to reduce the data collection interval defined in the sysstat cron jobs. By default, it is set to every 10 minutes, you can lower it to every 2 minutes.
You can do this in the /etc/cron.d/sysstat file:
# vi /etc/cron.d/sysstat
Save the file and close it.
Finally, enable and start the sysstat service using the following systemctl command:
systemctl enable --now sysstat.service systemctl enable sysstat.service
Next, wait for 2 minutes to start viewing sar reports. Use the sar command and the -b
command line option to report I/O and transfer rate statistics and -d
to report activity for each block device as shown.
sar -d -b
3. iotop – Monitor Linux Disk I/O Usage
Similar to top monitoring tool in terms of design, iotop is a simple utility that enables you to monitor disk I/O activity and usage on a per-process basis.
You can get it installed on your Linux server as follows (remember to run the appropriate command for your Linux distribution):
sudo apt install iotop [On Debian, Ubuntu and Mint] sudo yum install iotop [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux] sudo emerge -a sys-processs/iotop [On Gentoo Linux] sudo apk add iotop [On Alpine Linux] sudo pacman -S iotop [On Arch Linux] sudo zypper install iotop [On OpenSUSE]
To monitor per-process I/O activity, you can run iotop without any arguments as follows. By default, the delay between iterations is 1 second. You can change this using the -d
flag.
iotop OR iotop -d 2
iotop will by default display all threads of a process. To change this behavior so that it only shows processes, use the -P
command line option.
iotop -P
Also, using the -a
option, you can instruct it to display accumulated I/O as opposed to showing bandwidth. In this mode, iotop shows the amount of I/O processes performed since iotop was invoked.
iotop -P -a
That’s all we had for you! We would like to know your thoughts about this guide or the above tools. Leave a comment via the feedback form below.
You can also inform us about tools that you think are missing in this list, but deserve to appear here.