Is there any tool/command available in unix to monitor read/writes in a particular file.
I also want to collect how much data is being read each time the file is accessed.
|
Is there any tool/command available in unix to monitor read/writes in a particular file. I also want to collect how much data is being read each time the file is accessed. | |||
feedback
|
This question came from our site for professional and enthusiast programmers.
|
Short answer, none that I know of.
You could write a library that you would load with You could write a FUSE backend to do your accounting. It'd be slow, and it would slow down every process using that filesystem. The FUSE code also exposes a lot of kernel internals that expect fast results to arbitrarily long (and glacially long, by kernel standards) delays due to userspace programs. Programs might cause memory pressure, swapping, and further disk traffic. FUSE is best deployed in environments with plentiful memory, non-realtime requirements, and low cost of failure. | |||
|
feedback
|
|
THere is fam, http://en.wikipedia.org/wiki/File_alteration_monitor, but not sure if its available for your OS http://oss.sgi.com/projects/fam/ Also google inotify. | |||
|
feedback
|
|
In linux there have been several APIs for monitoring file system activity previously (dnotify and inotify), but the latest one is called For monitoring whole file systems there is iostat, what you ask for seems to be somewhat like iostat but only for a given file. I am not aware of such a combination, but by using the API you can write your own. | |||||
feedback
|
|
On Linux you can use incron. On Solaris/BSD you'll probably be able to get the information using DTrace. | |||
|
feedback
|