How to monitor disk activity per process?

Asked by Przemek K.

How can I check which process uses disk the most? I'm looking for something like top, but for hard disk (io) activity.
I've found pidstat from sysstat package, but it doesn't work. It shows no processes.

azrael@azrael-laptop:~$ pidstat -d -p ALL 5 10
Linux 2.6.22-14-generic (azrael-laptop) 23 kwi 2008

14:43:21 PID kB_rd/s kB_wr/s kB_ccwr/s Command

14:43:26 PID kB_rd/s kB_wr/s kB_ccwr/s Command

14:43:31 PID kB_rd/s kB_wr/s kB_ccwr/s Command

I have Ubuntu 7.10. Sometimes some program does heavy disk access on my system, which is slowing it a lot, and I want to know which program is the cause of disk heavy hard drive activity.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu iotop Edit question
Assignee:
No assignee Edit question
Solved by:
Przemek K.
Solved:
Last query:
Last reply:
Revision history for this message
Bhavani Shankar (bhavi) said :
#1

Hello

One easy thing to do is go 'System'-->'Administration;-->'System Monitor', that will give you a nice GUI display with some tabs you can click on to view what is going on inside your system.

Another quick, easy way to see what's going on is to open your terminal and use the command: top
The output from that command will show you all the processes running in your system and other important information.

If you want to be a little fancier, you can install Htop, just go 'Applications'-->'Add/Remove', and look in the 'System Tools' menu. Htop is nice, you will probably like that. As you would see from that link, Htop can be customized.

Also in the 'System Tools' menu in 'Add.Remove' is 'Hardinfo', and a real beauty: GKrellm, which I have in all my machines. GKrellm is a GUI display that depends on lm sensors which shows you just about everything, even hard drive temperatures, fan speeds, voltages, just about everything you want to know about.
Hint: if you can't find what you're looking for in 'Add/Remove', first make sure you have the 'Show' spinbox over in the top right corner set to 'All Open Source Applications', and if you still can't find things, make sure you have the right repositories enabled, Enable Repositories.

Regards

Bhavani Shankar.

Revision history for this message
Przemek K. (azrael) said :
#2

I know top, htop, and gnome-system-monitor. They don't show which process uses hard disk (not CPU or memory) the most. Many times the most hard-drive using process doesn't use much CPU or RAM.
I've found atop, but its disk activity monitoring doesn't work. ("No disk-activity figures available; request ignored!")

Revision history for this message
Przemek K. (azrael) said :
#3

It seems that atop requires a special kernel patch to monitor the disk activity per process.

Revision history for this message
Bhavani Shankar (bhavi) said :
#4

yes but did you try GKrellm and hardinfo

These tools are a real beauty as I said above..

Regards

Bhavani Shankar.

Revision history for this message
Przemek K. (azrael) said :
#5

Yes, they are nice, but they are not a solution to my problem. They only show the overall disk usage, not the disk usage of specific processes.

Revision history for this message
Bhavani Shankar (bhavi) said :
#6

OK..

Try out the command

du -h

which reports all the figures (Including disk usage per process) in an even easier form, specifying K for kilobytes, M for megabytes and so on

Regards

Bhavani Shankar.

Revision history for this message
Przemek K. (azrael) said :
#7

du shows how much space files take on disk, not how much disk a process uses.

Fortunately, I've found that pidstat (the command I mentioned in the question) works on hardy livecd, so it should work after I'll upgrade from gutsy to hardy.
Anyway, thanks for your attention Bhavani.

Revision history for this message
Bhavani Shankar (bhavi) said :
#8

yes.. Sorry for that... and no problems...:)

Revision history for this message
aqua (aquasov) said :
#9

Hi,

Just spent for about 15 minutes searching for a solution.
This is the thing you need:

http://guichaz.free.fr/misc/#iotop

Revision history for this message
MarkSeger (mark-seger) said :
#11

Try http://collectl.sourceforge.net/ as it has extensive support for process I/O. You can look at them in real-time as in a top command, play back old data, and even show threads. You can read more about it here: http://collectl.sourceforge.net/Process.html
-mark

Revision history for this message
ramnet (ramnet-ram) said :
#12

What you want is done using the "iotop" command / package.

Revision history for this message
MarkSeger (mark-seger) said :
#13

I guess part of it also comes down to how you want to look at the data. Collectl will run as a daemon, logging to files which you can then playback as many times as you wish and formatted in a number different ways each time for more effective data mining. You can even play it back in 'top' mode, showing top processes sorted by I/O users 'after the fact'. But it's your call....
-mark

Revision history for this message
viharm (viharm) said :
#14

ramnet's suggestion of 'iotop' is clearly the most efficient. Realtime monitoring of disk activity of each process - brilliant! I identified a rogue process which was writing at about 2.3 MB/s. Thanks.

Revision history for this message
Kalsan (info-kalsan) said :
#15

iotop is great stuff, exactly what I was looking for. Thanks!