How to check disk queue length on Linux

The average disk queue length is the average number of reads and writes queued for the selected device during a selected interval. It is important to watch them as these numbers are one of the representations of storage performance. Higher values ‚Äč‚Äčindicate that the crowd cannot continue with the requests from the appliance, resulting in higher response times.

In this tutorial we will learn how to Check the length of the disk queue with Linux Commands.

Using the iostat command

On Linux / Unix systems, the iostat command is mainly used to generate statistics on input / output devices.

the iostat Utility tool is part of the sysstat Package. If it isn’t found, install sysstat with the following command:


$ sudo apt install sysstat -y   [On ubuntu]
$ sudo yum install sysstat -y  [On centos]

For viewing average length of the disk queue Use iostat with the -x option, this gives advanced statistics. The field aqu-sz indicates the average queue length of the requests issued to the device or the integral average over the number of running IOs. In the old versions the field would be avgqu-sz.

$ iostat -x

iostat – Average disk queue length

Using the sar command

The Sar command is used to monitor the performance of Linux systems, including CPU, memory, and I / O, in real time. Sar is part of the sysstat package.

The Sar command with the -d option displays activity for each block device. To print the statistics with the actual device name, add another one -P Opportunity.

The field aqu-sz helps to find the average queue length. The field is the same for the iostat command.

$ sar -p -d 1 1 

sar command – check disk queue length

From / proc / diskstats

The / proc / diskstats file displays the I / O statistics of block devices. The result returned by this command is always the raw value.

From kernel version 5.5+, / proc / diskstats contains a total of 20 fields.

# 14 – weighted time spent on I / Os (ms)

The average disk queue length can be calculated by taking the data changes in the 14th field in a time span.

To view the contents of / proc / diskstats and filter for a specific disk, type:

$ cat /proc/diskstats | grep 'sda'

Output:

8       0 sda 15728 6935 1377412 10839 28870 15373 995570 49457 0 36360 60296 0 0 0 0 0 0

diploma

In this tutorial, we learned about various command line utilities to check disk queue length in Linux system.