I have a server (running CentOS 5) and I need to figure out which programs (MySQL, Apache, etc) are doing the most Disk I/O? Is there a command that will allow me to calculate an average over time?
4 Answers
Something like iotop will help, there are various versions so look at THIS one an google some others too.

- 101,299
- 9
- 108
- 239
-
I'm running a kernel higher than 2.6.20, but I keep getting errors about missing I/O accounting support (CONFIG_TASKSTATS, CONFIG_TASK_DELAY_ACCT, CONFIG_TASK_IO_ACCOUNTING). How would I go about adding those variables? – Steven Williams Apr 10 '11 at 02:21
You might try installing the sysstat package and use SAR and iostat. They give better visibility over a range of time if that is what you are looking for.
EDIT: Forgot the link...http://www.princeton.edu/~unix/Solaris/troubleshoot/diskio.html

- 1
- 1
Whilst sysstat is available for CentOS, the particular package you want doesnt come shipped with CentOS 5.
What you'll need to do is download sysstat from the main page which is here. Configure and compile it. The latest version comes with a program called pidstat. This program will give you what you want. It works much like other *stat utilities like iostat, mpstat and vmstat. Note to pass the -d flag.
You should not install this version, its binary incompatible with the files it creates. Just copy the pidstat program it compiled and stick it in /usr/local/bin instead.
pidstat -d 1 3
Linux 2.6.35.11-83.fc14.x86_64 (home.localdomain) 04/09/2011 _x86_64_(2 CPU)
07:39:40 PM PID kB_rd/s kB_wr/s kB_ccwr/s Command
07:39:41 PM PID kB_rd/s kB_wr/s kB_ccwr/s Command
07:39:42 PM 888 0.00 4.00 0.00 jbd2/dm-2-8
07:39:42 PM PID kB_rd/s kB_wr/s kB_ccwr/s Command
Average: PID kB_rd/s kB_wr/s kB_ccwr/s Command
Average: 888 0.00 1.32 0.00 jbd2/dm-2-8
The output should be pretty self explanatory.
Note that you need to be running a kernel that came with at least CentOS 5.4. Frankly if your not update anyway, there are numerous security reasons to do so and CentOS 5.6 was released very recently.

- 23,357
- 3
- 55
- 72
For monitoring IO output activity you can try with iostat, for example a basic usage is :
iostat -x [-d]
-x option displays extended statistics. You definitely want it. -d is optional. It removes CPU utilization to avoid cluttering the output.
Read the man pages for further information.

- 3,180
- 6
- 29
- 37