5 Linux commands for measuring disk activity

$ dstat -d 10
-dsk/total-
read writ
949B 73k
65k 81M

Notice that the reported data may be shown in a number of different units — e.g., M (megabytes), k (kilobytes), and B (bytes).

The dstat command provides valuable insights into overall Linux system performance, pretty much replacing a collection of older tools, such as vmstat, netstat, iostat, and ifstat, with a flexible and powerful command that combines their features. For more insight into the other information that the dstat command can provide, refer to this post on the dstat command.

2. iostat

The iostat command helps monitor system input/output device loading by observing the time the devices are active in relation to their average transfer rates. It’s sometimes used to evaluate the balance of activity between disks.

$ iostat
Linux 6.8.9-100.fc38.x86_64 (fedora) 11/05/2024 _x86_64_ (2 CPU)

avg-cpu: %user %nice %system %iowait %steal %idle
2.42 0.19 1.44 0.44 0.00 95.52

Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd
loop0 0.11 0.24 0.00 0.00 771 0 0
loop1 0.01 0.02 0.00 0.00 63 0 0
sda 25.13 685.20 175.07 102.58 2194224 560621 328480
zram0 3.98 0.94 15.27 0.00 3000 48900 0

Of course, all the stats provided on Linux loop devices can clutter the display when you want to focus solely on your disks. The command, however, does provide the -p option, which allows you to just look at your disks — as shown in the commands below.

$ iostat -p sda
Linux 6.8.9-100.fc38.x86_64 (fedora) 11/05/2024 _x86_64_ (2 CPU)

avg-cpu: %user %nice %system %iowait %steal %idle
2.21 0.17 1.35 0.41 0.00 95.86

Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd
sda 27.40 618.74 162.08 1297.02 2194423 574849 4600040
sda1 0.05 1.70 0.00 167.39 6022 1 593676
sda2 0.05 1.26 0.04 192.96 4469 152 684352
sda3 27.27 615.38 162.04 936.67 2182528 574696 3322012

Note that tps refers to transfers per second.

You can also get iostat to provide repeated reports. In the example below, we’re getting measurements every five seconds by using the -d option.



Source link