iotop – A top-Like I/O Monitoring Utility For Processes And Threads

If you are a system administrator then you would have definitely used the top or htop command to analyse CPU or memory consumption by processes in real-time. But, there are situations where you require a utility that could provide a real-time view of the process I/O in order to answer questions like – Why is the disk churning so much? If you have ever felt such a need then there exists a command line utility — iotop — that could solve your problem. In this article, we will discuss iotop through practical examples.

iotop – A Utility For I/O Monitoring

iotop is a top-like I/O monitoring utility that provides a real-time view of process/thread I/O on a system.

Here is a snapshot of its man page description :

Testing Environment

OS – Ubuntu 13.04

Shell – Bash 4.2.45

Application – iotop 0.4.4

A Brief Tutorial

Here is the syntax of this command :

$iotop [options]

So you can see that the iotop command expects some non-mandatory command line arguments.

Now, lets discuss iotop command through some practical examples.

1. The Default Output

In default mode, iotop command displays process/thread I/O related information in the following way :

So you can see that this command produces disk-read and disk-write information of all the processes and threads in real-time. The output, just like top command output, refreshes itself after a every one second.

2. Show Process Actually Involved In I/O

As can be observed in the default output (example-1), information related to all the processes/threads is shown irrespective of whether they are actually involved in I/O or not. If you want to see only those processes/threads that are actually involved then you can press ‘o’ while the default output is being displayed.

Here is a snapshot of iotop output when I pressed ‘o’ :

So you can see that only one process was displayed in the output.

3. Display The Output In Batch Mode Through -b Option

By default, the output of the iotop command is displayed in interactive mode. But, if you want to store the output in log-files then you can use command line option -b to display the output in batch mode.

Here is a snapshot of batch mode output of the iotop command :

So you can see that the output is produced in batch mode. You can use -n option to set the number of iterations after which the iotop command will quit.

4. Set A List OF Processes To Monitor Through -p Option

If it is required to monitor only a particular set of processes through iotop command then this can be done through -p option. You can pass a comma separated list of process IDs (PIDs) to -p option when executing the iotop command.

For example, I executed the iotop command in the following way :

$ iotop -p 3112 -p 1

and here is the output of the iotop command :

So you can see that only process I/O details of the corresponding processes were monitored in this case. Similarly you can use -u option to monitor processes based on users.

5. Show Accumulated I/O Through -a option

If you want iotop to show an accumulated amount of I/O that the processes/threads have done since the iotop command was executed, use the -a option.

Here is an example :

So you can see that the accumulated amount of I/O for each process/thread is displayed in the output.

For more command line options, refer to the man page of the iotop command.

Download/Install/Configure

Users can alternatively download the iotop command through command line download managers like apt-get, yum etc. Ubuntu users can use Ubuntu Software Centre to download this command line utility easily.

Pros

A utility exclusively for process I/O analysis

Provides information in real-time

Cons

It requires Python ≥ 2.7 and a Linux kernel ≥ 2.6.20 with the TASK_DELAY_ACCT CONFIG_TASKSTATS, TASK_IO_ACCOUNTING and CONFIG_VM_EVENT_COUNTERS options on.

It requires root privileges to execute.

Conclusion

If you want a utility that can effectively display the details of process/thread I/O in real-time then iotop is for you. It has certain requirements related to python/Linux-kernel version and kernel configuration macros but should work on most of the Linux systems without any major effort. Try it, it does what it promises.

Share this:

About Himanshu Arora

Himanshu Arora is a software programmer, open source enthusiast and Linux researcher. He writes technical articles for various websites and blogs. Some of his articles have been featured on IBM developerworks, ComputerWorld and in Linux Journal. He is the administrator of the blog and also contributes useful posts on the blog. Visit his google+ profile or mail him at himanshuz.chd[at]MAILSERVER[dot]com (where MAILSERVER=gmail)

Himanshu Arora is a software programmer, open source enthusiast and Linux researcher. He writes technical articles for various websites and blogs. Some of his articles have been featured on IBM developerworks, ComputerWorld and in Linux Journal. He is the administrator of MyLinuxBook and also contributes useful posts on the blog. When he is not busy writing articles, he likes to explore various food joints in his city, explore new hill stations and party at weekends. You can catch him on Google+.