Open Source

Gather disk usage statistics with iostat

The iostat tool monitors I/O (Input/Output) performance related to disk drives. Find out how you can use iostat to better manage your network.

System monitoring is an important part of network administration. Fortunately, there are numerous tools on the market that monitor performance, network activity, and SMART status of hard drives. One tool that isn't very well known is called iostat, and it monitors I/O (Input/Output) performance related to disk drives.

Some Linux distributions ship with iostat. If your distribution doesn't include it, simply download the iostat source code and build it as follows:

$ tar xvzf iostat-2.2.tar.gzcd iostat-2.2make

When the build is complete, you'll have the tool iostat and the manpage iostat.8 in the current directory. To install iostat and its manpage in the /usr/local directory tree, simply perform a "make install":

$ tar xvzf iostat-2.2.tar.gzcd iostat-2.2make install

You can run iostat with a number of options and two optional arguments: "interval" and "count." To view disk activity over time, provide it with an interval of 15 (seconds) and a count of 10 (samples). Here's how:

$ ./iostat 15 10

However, this will give you only basic information on the installed physical disk drives. To obtain more information, pass iostat a few more options, such as printing statistics per disk (-d), printing CPU activity stats (-c), including per-partition stats (-p), and including extended statistics (-x). For a good sampling of data, enter this code snippet:

$ ./iostat -Dpxc

Since iostat prints out a lot of information, you'll want to keep the manpage handy so that you can identify what each column means. Some of the information includes total transfer rate per second, total number of requests per second, number of reads (and writes) per second, percentage of CPU time spent in user, system, and idle modes, and much more.

If your system is slowing down and you're having a hard time finding the bottleneck, iostat may clue you in on some problem areas. Even before that slowdown, iostat can tell you what disks are over- and under-utilized, which allows you to plan ahead and balance the I/O load.

Delivered each Tuesday, TechRepublic's free Linux NetNote provides tips, articles, and other resources to help you hone your Linux skills. Automatically sign up today!

About Vincent Danen

Vincent Danen works on the Red Hat Security Response Team and lives in Canada. He has been writing about and developing on Linux for over 10 years and is a veteran Mac user.

Editor's Picks

Free Newsletters, In your Inbox