www.LinuxHowtos.org

edit this article

Iotop

When a process is slowing down a computer that has plenty of extra memory and disk space, it is probably because of cpu usage or input/output (I/O). Most users are used to using top to locate those pesky CPU and memory hogs, but few have ever used iotop to find the disk usage hogs.

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.

If it complains about missing kernel options (TASKSTATS and TASK_IO_ACCOUNTING), then you will need to recompile your kernel with the options shown below.

Code Listing 1
Configuring the kernel for iotop
+----------------------------------------------------------------------------+
| General Setup --> |
| [*] Export task/process statistics through netlink |
| [ ] Enable per-task delay accounting |
| [*] Enable extended accounting over taskstats |
| [*] Enable per-task storage I/O accounting |
+----------------------------------------------------------------------------+


Once you've booted into your reconfigured kernel, you can run iotop from the
commandline. Here's what it might look like if you were backing up a DVD:

Code Listing 2
+-----------------------------------------------------------------------------+
| $ iotop |
| Total DISK READ: 387.25 K/s | Total DISK WRITE: 221.29 K/s |
| PID USER DISK READ DISK WRITE SWAPIN IO> COMMAND |
| 7703 root 387.25 K/s 0 B/s 0.00 % 0.00 % tccat -i /shared/... |
| 211 root 0 B/s 13.83 K/s 0.00 % 0.00 % [pdflush] |
| 7672 root 0 B/s 207.46 K/s 0.00 % 0.00 % transcode -H 10 ... |
+-----------------------------------------------------------------------------+


A misbehaving user might have the following output:
Code Listing 3
+-------------------------------------------------------------------------------------+
| $ iotop |
| Total DISK READ: 5.21 K/s | Total DISK WRITE: 7.37 M/s |
| PID USER DISK READ DISK WRITE SWAPIN IO> COMMAND |
| 7936 user1 5.21 K/s 7.37 M/s 0.00 % 0.00 % dd if /dev/zero of ./bigfile |
+-------------------------------------------------------------------------------------+


iotop is a good way to see what's eating your disks, so that you can
reallocate resources when needed. The program has a few options available, so
run iotop --help to get a summary of its capabilities.

rate this article:
current rating: average rating: 1.7 (84 votes) (1=very good 6=terrible)
Your rating:
Very good (1) Good (2) ok (3) average (4) bad (5) terrible (6)

back