Watching Hard Drive Activity With iotop On Ubuntu 8.10 And Debian Lenny

Want to support HowtoForge? Become a subscriber!
 
Submitted by falko (Contact Author) (Forums) on Fri, 2009-02-20 17:38. :: Debian | Ubuntu

Watching Hard Drive Activity With iotop On Ubuntu 8.10 And Debian Lenny

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 02/09/2009

This article shows how you can watch your hard drive activity with iotop on Ubuntu 8.10 and Debian Lenny. iotop watches I/O usage information output by the Linux kernel (requires 2.6.20 or later) and displays a table of current I/O usage by processes or threads on the system. iotop displays columns for the I/O bandwidth read and written by each process/thread during the sampling period. It also displays the percentage of time the thread/process spent while swapping in and while waiting on I/O. In addition the total I/O bandwidth read and written during the sampling period is displayed at the top of the interface.

I do not issue any guarantee that this will work for you!

 

1 Installing iotop

Both Ubuntu 8.10 and Debian Lenny have iotop packages in their repositories, therefore the installation is very easy:

Ubuntu 8.10:

sudo apt-get install iotop

Debian Lenny:

apt-get install iotop

 

2 Usage

Usage is similar to the top program, you just type

iotop

and you will get a table of hard drive activity, updated every second:

Total DISK READ: 0 B/s | Total DISK WRITE: 706.11 K/s
  PID USER      DISK READ  DISK WRITE   SWAPIN    IO>    COMMAND
 4288 root           0 B/s  706.11 K/s  0.00 %  0.00 % sftp-server
    1 root           0 B/s       0 B/s  0.00 %  0.00 % init
    2 root           0 B/s       0 B/s  0.00 %  0.00 % [kthreadd]
    3 root           0 B/s       0 B/s  0.00 %  0.00 % [migration/0]
    4 root           0 B/s       0 B/s  0.00 %  0.00 % [ksoftirqd/0]
    5 root           0 B/s       0 B/s  0.00 %  0.00 % [watchdog/0]
    6 root           0 B/s       0 B/s  0.00 %  0.00 % [events/0]
    7 root           0 B/s       0 B/s  0.00 %  0.00 % [khelper]
 3597 syslog         0 B/s       0 B/s  0.00 %  0.00 % syslogd -u syslog
 3758 mysql          0 B/s       0 B/s  0.00 %  0.00 % mysqld --basedir=/usr --d
 3909 root           0 B/s       0 B/s  0.00 %  0.00 % sshd: root@pts/0
  152 root           0 B/s       0 B/s  0.00 %  0.00 % [pdflush]
  153 root           0 B/s       0 B/s  0.00 %  0.00 % [pdflush]
  154 root           0 B/s       0 B/s  0.00 %  0.00 % [kswapd0]
 3760 mysql          0 B/s       0 B/s  0.00 %  0.00 % mysqld --basedir=/usr --d
 1309 root           0 B/s       0 B/s  0.00 %  0.00 % [mpt_poll_0]
 3635 messageb       0 B/s       0 B/s  0.00 %  0.00 % dbus-daemon --system
 3615 root           0 B/s       0 B/s  0.00 %  0.00 % dd bs 1 if /proc/kmsg of
 3617 klog           0 B/s       0 B/s  0.00 %  0.00 % klogd -P /var/run/klogd/k
 3901 root           0 B/s       0 B/s  0.00 %  0.00 % getty 38400 tty1
 3548 root           0 B/s       0 B/s  0.00 %  0.00 % getty 38400 tty4
 3754 mysql          0 B/s       0 B/s  0.00 %  0.00 % mysqld --basedir=/usr --d

Type q to leave iotop.

To learn more about iotop and additional options, take a look at its man page:

man iotop

 

3 Links


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by zImage (not registered) on Sat, 2009-04-11 15:35.

Definitely that’s a step in the right direction.

Unfortunately it’s still hard to tell who’s wasting most disk IO in too many situations.

Suppose you have two processes - dd and mysqld.

dd is doing massive linear IO and its throughput is 10MB/s. Let’s say dd reads from a slow USB drive and it’s limited to 10MB/s because of the slow reads from the USB.

At the same time MySQL is doing a lot of very small but random IO. A modern SATA 7200 rpm disk drive is only capable of about 90 IO operations per second (IOPS).

So ultimately most of the disk time would be occupied by the mysqld. Still iotop would show dd as the bigger IO user.

Btw, there's also atop which is a good multi-purpose top like tool. It shows CPU, IO, Network load and more. There's also the atop kernel patch that adds some extra performance counters.

– Teodor Milkov

Submitted by Anonymous (not registered) on Mon, 2009-02-23 23:00.

When tuning notebook for better battery life I have found "pidstat" tool irreplaceable. 

 "pidstat -d 10" would show every 10 seconds list of processes which did I/O.

Very handy.

IIRC it is part of sysstat package.

Submitted by Anonymous (not registered) on Mon, 2009-02-23 19:21.
Why did you use sudo apt-get  with Ubuntu and only apt-get with Lenny?  Got something against Lenny?   The way my Lenny's set up I need root permission to use apt-get, for security reasons.
Submitted by admin (registered user) on Mon, 2009-02-23 19:37.
I use apt-get because I log in as root on Debian. On Ubuntu, I don't enable the root account because this is frowned upon by the Ubuntu community. Therefore I use sudo.
Submitted by sjau (registered user) on Fri, 2009-02-20 18:01.

nice, been looking for a long time for something like that. Now if there only was a nice colorful ncurses based version of it, you know like top --> htop ;)

 Thx for that article.