Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to find a program that actively monitors how much data is read and written per second to open files and then sorts files with the highest usage at the top. This would be similar to iotop but on a per-file basis instead of per-thread or per-process. It would also be identical to the Disk tab in Windows 7 Resource Monitor. Any suggestions? Thanks

share|improve this question

2 Answers 2

I think something based on lsof might work, but I haven't really used it.

There's a bunch of example scripts here: http://fts.ifac.cnr.it/cgi-bin/dwww/usr/share/doc/lsof/examples/?type=dir That might give you clues on how to do what you want.

share|improve this answer
    
I briefly saw lsof mentioned during my searches. After browsing through man lsof, I don't believe it gives read or write bytes/second. I hadn't seen those example scripts, but after looking, I couldn't find anything bytes/second related in there either. It also wouldn't be my first choice to write a fairly lengthy script just to parse output. Hopefully someone knows of a better tool. –  mach Aug 1 '12 at 14:25

Hmm, gross :)

Closest I could find is stap module that did io stats on process level basis.

NOTE: Systemtap can change your kernel internals at runtime, USE AT YOUR OWN RISK! https://wiki.ubuntu.com/Kernel/Systemtap

This script:

http://sourceware.org/systemtap/wiki/Scripts/execname-iotop

Uses vfs_read/write to get a gross IO's executed on behalf of process X. You'll notice that vfs_read takes struct file as an argument so it you were inclined to determine the actual file handle you could monitor io at that entry point.

I don't have a method to determine that off the top of my head and honestly it's some work to get it right. That's left as an exercise for the OP. You might wish to check out Linux "perf", there might be a ready method there.

Or you might want to reconsider your entire approach.

share|improve this answer
    
Thanks. For my work, my original question has become irrelevant now. However, I still think a utility which had this feature would be beneficial. That being said, from the looks of it, I think your approach could be successful. However, I would like wait and see if anyone else has a better answer. –  mach Oct 4 '12 at 15:08
    
Oh I'm sure it would be beneficial, I could write it myself were I so inclined, unfortunately it's a matter of time and inclination. I think you might be waiting a long time... Or you could tinker with that example and contribute the new tool back to the community. –  ppetraki Oct 4 '12 at 17:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.