Sunday, February 21, 2010

Ubuntu disk i/o analysis

Very quick rundown of some commands can tell you things about your disk IO. If I feel like it in the future, I'll expand this to a more documented post.



What processes have files open
lsof
Use this as "lsof /srv" to show all open files under /srv (else you'll get loads of output). 

Which processes are using which disk IO
iotop

note: might need to install package sysstat

Which processes are using a partition
btrace -s /dev/sda1
Just quit the btrace with a CTRL-C. This will give you a (rather large) report on which processes are using disc and what for (reads/writes/etc..)
note: might need to install package blocktrace

Quick realtime overview of generic disc I/O info
watch --interval 1 iostat
Will show you cpu usage, and also the amount of transfers p/second, blocks read & written p/sec, etc..
The watch command is just so the output is refreshed every second, you can also just run iostat.

Longer overview of generic system info
Other good tools that let you check real time generic system info that also includes I/O wait is vmstat, just run it as the following, the 1 being the refresh time. The BO and BI headers are for blocks in/out. Also might be usefull to check if processes are being blocked or how much the cpu is waiting (could be on disk io).
vmstat 1


Another way of looking at the generic system info, but now also for the past is sar. You have to install this first (apt-get install sysstat), and enable the daemon in /etc/default/sysstat. And possibly restart the daemon to effectuate. This will then start collection system data that can be viewed by the sar command, keeping 12 hours worth of data.

No comments:

Post a Comment