Installing IOTop on CentOS5
Iotop is a Python program with a top like UI used to show of behalf of which process is the I/O going on. This can come in handy for administrators trying to track down a specific process that may be causing a disk I/O bottleneck.
Pre-Requisites
IOTop uses features that are a part of a newer kernel build than what CentOS ships with, so you must upgrade your kernel to at least 2.6.20. The process of doing so is outside of the scope of this article; guides can be easily found through a quick search online. If you are on our VPS, this is as easy as logging into your VPS manager, selecting your current profile under Server Manager, and changing your kernel to NDCHost LATEST. If you are building your own, make sure the version you build supports I/O accounting (CONFIG_TASKSTATS, CONFIG_TASK_DELAY_ACCT, CONFIG_TASK_IO_ACCOUNTING).
This program also requires a newer Python version than CentOS 5 supplies (2.6 vs 2.4), so we'll grab those from the EPEL repo and install them:
rpm -ivh ftp://ftp.sunet.se/pub/Linux/distributions/fedora/epel/epel/5/i386/python26-2.6.5-5.el5.i386.rpm \ ftp://ftp.sunet.se/pub/Linux/distributions/fedora/epel/epel/5/x86_64/python26-libs-2.6.5-5.el5.i386.rpm \ ftp://ftp.pbone.net/mirror/download.fedora.redhat.com/pub/fedora/epel/5/i386/libffi-3.0.5-1.el5.i386.rpm
If these installed successfully, you are now ready to install IOTop.
Installing & Configuring IOTop
Let's install the RPM:
rpm -ivh http://guichaz.free.fr/iotop/files/iotop-0.4.1-1.noarch.rpm
Now, CentOS will typically keep Python2.4 as your default Python, so we can tell IOTop to use Python 2.6 in two ways. One would be to relink the /usr/local/bin/python
binary to /usr/local/bin/python2.6
, or we can simply change the sha-bang at the beginning of the iotop script to use he 2.6 binary instead. We choose the latter so as to not break compatibility with Python2.4-exclusive scripts.
So, edit /usr/bin/iotop
and change the first line so the script looks like the following:
#!/usr/bin/python2.6 # iotop: Display I/O usage of processes in a top like UI # Copyright (c) 2007, 2008 Guillaume Chazarain <guichaz@gmail.com>, GPLv2 # See iotop --help for some help import sys try: from iotop.ui import main except ImportError, e: print e print 'To run an uninstalled copy of iotop,' print 'launch iotop.py in the top directory' else: try: main() except KeyboardInterrupt: pass sys.exit(0)
Usage
Using iotop is fairly straightforward. All of the options are explained in detail by the manual, so give that a glance over to answer most of your questions. The interface looks and functions almost exactly like top, so if you are familiar with it's usage, iotop will be a breeze.