1

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

2 Answers 2

0

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.

1
  • 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, 2012 at 14:25
0

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.

2
  • 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, 2012 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, 2012 at 17:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .