Print I/O operations per-process by iopp

Xaprb.com shows a nice example on how to print I/O operations per-process by iopp here. This command is only available in kernel-2.6.20+ or equivalent patched, so they don’t work for older linux systems (including RHEL4, 5.0, 5.1, 5.2).

What is ‘iopp’? It’s a custom tool to go through the Linux process table to get i/o statistics per process. It is open source and can be downloaded from: http://git.postgresql.org/?p=~markwkm/iopp.git;a=summary

baron@kanga:~$ wget -q -O iopp.c "http://git.postgresql.org/?p=~markwkm/iopp.git;a=blob_plain;f=iopp.c;hb=HEAD"
baron@kanga:~$ gcc -o iopp iopp.c
baron@kanga:~$ ./iopp --help
usage: iopp -h|--help
usage: iopp [-ci] [-k|-m] [delay [count]]
-c, --command display full command line
-h, --help display help
-i, --idle hides idle processes
-k, --kilobytes display data in kilobytes
-m, --megabytes display data in megabytes

An output example:

baron@kanga:~$ ./iopp -i -k 5

pid    rchar    wchar    syscr    syscw      rkb      wkb     cwkb command
4912        2        1        0        0        0        0        0 dbus-daemon
5713        0        1        0        0        0        0        0 hald
5717       17        0        0        0        0        0        0 hald-runner
5932        0        2        0        0        0        0        0 NetworkManager
22101       94       28        0        0        0        0        0 Xorg
22238        4        4        0        0        0        0        0 pulseaudio
22684       29       55        1        0        0        0        0 firefox
26860        0       43        0        0        0        0        0 gnome-terminal

It behaves just like vmstat.  I don’t see any documentation, but I see from the source that it’s reading /proc/[PID]/io. Unfortunately that’s not documented in my proc manpage, but there’s a patch that provides documentation for the file’s contents.

According to that, we’re looking at the pid, the number of kibibytes read and written (even if they came from the cache), the number of read and write system calls, and the number of kibibytes read and written to physical medium (i.e. not just to the OS cache). Finally we have canceled write kibibytes, and the command name. I won’t repeat the documentation on the canceled write bytes — it is what it sounds like, but there’s a little bit more explanation on that patch I linked.

Share Button

Leave a comment

Your email address will not be published. Required fields are marked *