Monitoring Disk Usage With Iotop
If you want to keep an eye on the CPU usage of your processes, you can use top. For disk I/O, the Python program iotop does the same thing, which can be extremely useful if you're experiencing hard disk thrashing.Tip of the Trade: Hard disk thrashing? Check out Iotop, a Python program similar to top that enables you to keep an eye on disk I/O.
iotop is available as a package for Debian and Ubuntu, and it should work out-of-the-box if you're running a standard kernel. If you're installing from source, you'll need Python 2.5 or later and a 2.6.20 or later kernel with the TASK_DELAY_ACCT and TASK_IO_ACCOUNTING options enabled.
The basic output is easy to read; it looks a lot like top. For each process, it shows disk read, disk write, percentage of time spent while swapping, percentage of time spent swap space used and percentage of time spent waiting on I/O. You can use the left and right arrows to change which column the display sorts on and hit "r" to reverse the sort order for that column.
By default, all processes are shown, but you can use iotop --only, or hit o during the display, to show only processes or threads actively doing I/O. You can also limit it to processes (rather than including all threads) with the -P command-line option. Finally, for non-interactive I/O monitoring, use iotop --batch -n 5 < iotop.out to run five iterations and output to iotop.out.
If for some reason you can't use iotop, you can use vmstat 1 instead and look at the bi and bo columns. This, however, is far less human-readable, and it doesn't include dynamic reordering options. It's well worth having iotop available on your systems.
Juliet Kemp has been messing around with Linux systems, for financial reward and otherwise, for about a decade. She is also the author of "Linux System Administration Recipes: A Problem-Solution Approach" (Apress, 2009).
IT Solutions Builder TOP IT RESOURCES TO MOVE YOUR BUSINESS FORWARD
Which topic are you interested in?
What is your company size?
What is your job title?
What is your job function?
Searching our resource database to find your matches...