In the next article we are going to take a quick look at how we can monitor disk I / O performance in Ubuntu using iotop and iostat tools. As a general rule, users can use the command top to know the execution processes of the system (and more things) in real time and identify potential problems. But if we don’t find any performance issues with regard to resource utilization, especially CPU and memory, it is interesting to move on to checking other fields to identify bottlenecks.
In the command output top there are fields we can use to find out if there are high I / O read and write operations on storage devices and partitions. If disk I / O operation is high, it may be the cause of performance lag, so the disk I / O statistics in the system should be verified, and this is where the iotop and iostat tools can help us.
Iotop and iostat to verify I / O statistics
To check the I / O statistics in detail, users can use the iotop and iostat commands. These commands are used to identify performance problems with storage devicesincluding local disks or the network file system.
What is iotop?
This utility It is similar to the top command, but it shows the disk activity in real time. This utility looks at the kernel I / O usage information and displays a table of the current I / O usage through processes or threads on the system. It also shows the bandwidth and the read and write I / O time of each process or thread.
This utility we can install easily with the help of apt package manager. For Debian / Ubuntu systems, we will only have to open a terminal (Ctrl + Alt + T) and execute the command:
sudo apt install iotop
Monitor disk I / O activity using iotop
There are many options available in the iotop command to check the various statistics about disk I / O. We will only have to execute the iotop command without any argument, even though we will have to run it with superuser privileges, to see each process or thread about the current I / O usage:
In order to check which processes are actually using disk I / O, we will have to add to the iotop command the -oo –only option:
sudo iotop --only
In order to see more options applicable to iotop, in a terminal we can consult your help with the command:
In order to remove iotop from our team, in a terminal (Ctrl + Alt + T) we will only have to execute:
sudo apt remove iotop
What is iostat?
The command iostat is used to monitor the load of the input / output device of the system, looking at how long devices are active in relation to their average transfer rates. It can also be used to compare activity between disks.
This command generates reports that can be used to change the system configuration to better balance the input / output load between the physical disks. The iostat command generates two types of reports; CPU utilization Y use of the device.
In multiprocessor systems, CPU statistics are calculated across the system as an average across all processors.
The tool iostat is part of the sysstat package, which can be installed from the official repository. We will only need to open a terminal (Ctrl + Alt + T) and execute the command in it:
sudo apt install sysstat
Measuring disk I / O performance with the iostat command
There are many options available in the iostat command to check various CPU and disk I / O statistics. If we execute the iostat command without any argument we can view full system statistics:
If we add the -d option to the iostat command, we can view I / O statistics for all devices:
On the other hand, if we add the -p option to the iostat command, we will show I / O statistics of all devices and their partitions.
If what interests us is view detailed I / O statistics for all devices, we will only need to add the -x option to the iostat command:
If we are interested know the I / O statistics of block devices and all their partitions used by the system, we just need to add the -p option followed by the device name:
iostat -p sda
In order to remove iostat from our team, we just need to open a terminal (Ctrl + Alt + T) and execute in it:
sudo apt remove sysstat
We have just seen two more tools that can help a system administrator to detect disk performance problems using commands iotop and iostat. For more information, the user who wants can consult the fountain of this article.