How to track server disk activity on Linux with iostat

Friday, 11th March 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

Share this on:

Download PDFDownload PDF

Tags:

3 Responses to “How to track server disk activity on Linux with iostat”

  1. TimDaMan says:
    Firefox 3.6.15 Firefox 3.6.15 Windows 7 Windows 7
    Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15

    You don’t need to use iostat with the “watch” command. iostat supports a refresh interval argument.For example to get output every 2 seconds

    iostat -p -m 2

    On the other hand “watch” does produce prettier output.

    View CommentView Comment
  2. OERNii says:
    Firefox 38.0 Firefox 38.0 Fedora x64 Fedora x64
    Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0

    Also, running iostat in watch shows very skewed results, as iostat needs to buffer the first round of numbers and only the second one show meaningful data. Running “watch iostat” only show the first, incorrect data.

    View CommentView Comment

Leave a Reply

CommentLuv badge