Pular para o conteúdo
,

iotop, your best friend when LED of HD stays on

How to verify which process is using the disk and how much it is using. This way it's possible to know where the bootleneck is with iotop on Linux

Avatar de DK
DKTrabalha com Linux e Unix a mais de 23 anos e possui as certificações LPI 3, RHCE, AIX e VIO.

15 set, 2009
5 min de leitura
WARNING: This article is a museum piece (2009)!

If you landed here because your server is freezing today, please do not follow this tutorial (nobody needs to compile a kernel manually to use iotop anymore).

I have written a fully revised, updated, and modern version for the current landscape.

Click here to read the new version: Your server is slow? iotop will tell you who’s to blame

The server is slow to hell, badly accessing remotely, a simple ls it’s enougth to take a lot of seconds running… openning a program, no way… lot of minutes, time to take a cup of coffee.

You, don’t understanding what’s goin on, go get a look at the server, sometimes wishing to reset it, then, surprisely see that the HD LED look’s like the POWER one, but, Red…

In situations like that where are a lot of disk activities, come the question “What now?”, how to verify what is doing such a lot of disk access?

I will show you how to install iotop on Linux Red Hat / CentOS servers.

For that, there’s a very handy tool, iotop, it have a very nice CLI interface that show the I/O data. Utilize the very own values that kernel pass throught and show us in a very fancy interface :)

Screenshot-root@localhost:-usr-src-iotop-0.3.1

Needs to have Python >= 2.5 and kernel Linux >= 2.6.20 with those options enabled

  • CONFIG_TASKSTATS
  • CONFIG_TASK_DELAY_ACCT
  • CONFIG_TASK_IO_ACCOUNTING

Pre-requisites

wget http://guichaz.free.fr/iotop/files/iotop-0.3.1.tar.bz2
tar jxvf iotop-0.3.1.tar.bz2 -C /usr/src
cd /usr/src/iotop-0.3.1/

To execute the program without installing it, just call via CLI:

./iotop.py

In case that the following error comes:

Traceback (most recent call last):
  File "./iotop.py", line 8, in ?
    from iotop.ui import main
  File "/usr/src/iotop-0.3.1/iotop/ui.py", line 12, in ?
    from iotop.data import find_uids, TaskStatsNetlink, ProcessList
  File "/usr/src/iotop-0.3.1/iotop/data.py", line 12, in ?
    from iotop import ioprio, vmstat
  File "/usr/src/iotop-0.3.1/iotop/ioprio.py", line 1, in ?
    import ctypes

It’s because you haven’t the python installed os it isn’t the 2.5 version. It’s necessary to install it.

Installing Python 2.5 on Red Hat 5.3 / CentOS 5.3

Red Hat 5 / CentOS 5 comes with python 2.4 by default. It isn’t cool to simply install the new version over the default one, instead, I’m disponibilizing here the RPMs of python 2.5 for Red Hat 5 / CentOS 5 that will be installed in his own directory /usr/bin/python25, so, the scripts that Yum and others scripts made use of python 2.4 won’t get hurt.

The news is, always that you need to use the new version of python 2.5 you’ll have to change the interpretor PATH that call python25. It’s better than the whole system going unstable, isn’t it? ;)

Executing iotop.py

With python25 installed, it’s time to modify the script iotop.py and change the interpreter on the first line, from:

#!/usr/bin/python

to

#!/usr/bin/python25

Ok, time to run the script

./iotop.py

If any of the pre-requisites won’t be safisfied, a message like this one will show informing what is missing

Could not run iotop as some of the requirements are not met:
- Python >= 2.5 for AF_NETLINK support: Found
- Linux >= 2.6.20 with I/O accounting support (CONFIG_TASKSTATS, CONFIG_TASK_DELAY_ACCT, CONFIG_TASK_IO_ACCOUNTING): Not found

Python 2.5 it’s OK, but kernel isn’t.

Simple, compiling kernel with those options:

To compile the new kernel, there’s a post here that explains it, here I’ll show you just which options to be considered, compile and install the kernel it’s with you now ;)

General setup  --->
...
[*] Export task/process statistics through netlink (EXPERIMENTAL)
[*]   Enable per-task delay accounting (EXPERIMENTAL)
[*]   Enable extended accounting over taskstats (EXPERIMENTAL)
[*]     Enable per-task storage I/O accounting (EXPERIMENTAL)
...

Screenshot-3

Kernel 2.6.30.5 (rpm) with process statistics ready to be used with iotop

To install

rpm -ivh kernel-2.6.30.5fogonacaixadagua-1.i386.rpm

in case you already installed this kernel before, will need to generate again an image initrd and use the flag --force with rpm -ivh --force command.

iotop running

Screenshot-root@localhost:-usr-src-iotop-0.3.1

Installing iotop

Into the directory you extracted iotop-0.3.1 run the command
./setup.py install

cd /usr/src/iotop-0.3.1
./setup.py install

How it was installed python 2.5, if you run /usr/bin/iotop the following error will be gracefuly show to you

Traceback (most recent call last):
File "/usr/bin/iotop", line 4, in 

import pkg_resources
ImportError: No module named pkg_resources

To resolve that one, it’s quite simple, into directory where you extracted iotop, in this case /usr/src/iotop-0.3.1 copy the entire directory iotop to /usr/lib/python-2.5

cd /usr/src/iotop-0.3.1
cp -Rp iotop /usr/lib/python2.5/

And after that, edit the file /usr/bin/iptop and modify the line of interpreter

from

#!/usr/bin/python

to

#!/usr/bin/python25

Ok, iotop running!

Avatar de DK

Comentários

Comentários fechados para visitantes. Entre ou registre-se para comentar.

9 respostas para “iotop, your best friend when LED of HD stays on”

  1. Avatar de DK

    To install iotop on Debian etch, follow this link http://www.fogonacaixadagua.com.br/lz

  2. Avatar de Nikanth Karthikesan
    Nikanth Karthikesan

    Checkout ullae-veliyae http://lizards.opensuse.org/2009/07/23/ullae-veliyae-hackweek/

    The source is available at http://gitorious.org/ullae-veliyae/

    This java tool plots a graph, so you get an idea of history rather than just the last time-slice

    1. Avatar de DK

      Thanks for the tip Nikanth!

      1. Avatar de Blessing

        Thank you and glad this hleepd. I wish I had been able to post it sooner–more on that in another post.

  3. Avatar de DK

    Users of Mac OS X already have iotop installed.

    Just run ‘iotop’ from Terminal, easy breeze ;)

  4. Avatar de Mark

    I’ve downloaded your python-2.5.1 rpm files but can’t install because each one claims it’s has a dependency in one of the others.

    python25-2.5.1-fogonacaixadagua2.i386.rpm says libpython2.5.so.1.0 is needed by python25-2.5.1-fogonacaixadagua2.i386

    python25-libs-2.5.1-fogonacaixadagua2.i386.rpm says 2.5.1-fogonacaixadagua2 is needed by python25-libs-2.5.1-fogonacaixadagua2.i386

    I am using rpm -ivh. How are these to be installed?

    1. Avatar de DK

      You can install them using

      yum localinstall python25-libs-2.5.1-fogonacaixadagua2.i386.rpm python25-2.5.1-fogonacaixadagua2.i386.rpm

      Post here your results!

  5. Avatar de Sandy Pfendler

    Stumbled into this site by chance but I’m sure glad I clicked on that link.

  6. […] may fix the problem , and i must compile a new kernel rpm with configurations that i need . iotop, your best friend when LED of HD stays on | Fogo na Caixa dAgua Compilando kernel no Linux CentOS 5.3 / Red Hat 5.3 | Fogo na Caixa dAgua also yum donot detect […]

Ir para