Posts Tagged ‘How to track server disk activity on Linux with iostat’

How to track server disk activity on Linux with iostat

Friday, March 11th, 2011

If you need to check the read/write throughput on a Linux just like I needed recently you might want to checkout iostat

This little handy tool is part of the Linux performance tools bundled together in the package sysstat

There is plenty of information that iostat can provide you with concerning your hard drive activity however the most basic one which I need and use is:

debian:~# watch iostat -p -m

You will get output from the command similar to:

Every 2.0s: iostat -p -m Fri Mar 11 14:11:14 2011

Linux 2.6.26-2-amd64 (debian) 11/03/11 _x86_64_

avg-cpu: %user %nice %system %iowait %steal %idle
2.61 0.07 1.45 0.78 0.00 95.08

Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtn
fd0 0.00 0.00 0.00 0 0
sda 20.54 0.66 0.24 15546337 5620965
sda1 20.06 0.65 0.23 15431880 5407656
sda2 0.48 0.00 0.01 114455 213309
sdb 20.04 0.59 0.29 14032121 6836186
sdb1 20.02 0.59 0.29 14026659 6830632
sdb2 0.02 0.00 0.00 5460 5553
md0 62.91 0.10 0.22 2421986 5306950

In the above command I also use the watch command in order to execute the iostat -p -m command continuously every 2 seconds to refresh the output results.
The -p option without an option will automatically show statistics for all hard drives and the -m option is passed in order to show the statistics in megabytes instead of blocks