Skip to contentSkip to conversation

Looking for a file monitor

DISCUSSION Wei Hu 3 participants 8 messages Feb 24, 2006 – Feb 25, 2006 1 message not in the archive

lore
Share & tools
lore

Wei Hu

author
#0 lore raw

Hi there,

I'm looking for a file monitor for Linux, basically like filemon
(http://www.sysinternals.com/Utilities/Filemon.html) for Windows. But it looks like filemon for Linux has been discontinued.

I looked into dnotify but it was not what I'm looking for. I want a monitor program that can intercept all file access of any process that satisfy a given filter. Is there a program? I searched on Google but had no luck.

Thanks,
Wei

author
#2 lore raw

Thanks for the information.
I understand inotify is a replacement for dnotify. But I still don't get the advantages of it. What kind of events can I watch?

Quoted 11 lines · Hareesh Nagarajan
Quoted 4 lines · Wei Hu

I looked into dnotify but it was not what I'm looking for. I want a monitor program that can intercept all file access of any process that satisfy a given filter. Is there a program? I searched on Google but had no luck.

dnotify has been succeeded by inotify. check the link below:
http://www.kernel.org/pub/linux/kernel/people/rml/inotify/README

./hareesh

#4 lore raw
Quoted 11 lines · Diego Calleja
Quoted 2 lines · Hareesh Nagarajan

dnotify has been succeeded by inotify. check the link below:
http://www.kernel.org/pub/linux/kernel/people/rml/inotify/README

IIRC, inotify is not the best thing for examining system-wide events. Monitoring of directories is not recursive (neither it should, i think) so to examine the whole system you would need to need thousands of watches.

Surely.

But if we want to keep a track of all the files that are opened, read, written or deleted (much like filemon; ``Filemon's timestamping feature will show you precisely when every open, read, write or delete, happens, and its status column tells you the outcome."), we can write a simple patch that makes a note of these events on the VFS layer, and then we could export this information to userspace, via relayfs. It wouldn't be too hard to code a relatively efficient implementation.

Hareesh

author
#5 lore raw

Yeah, that's basically what I'm looking for.
So is it correct that I can keep track of all the actions as inotify events?

Quoted 10 lines

But if we want to keep a track of all the files that are opened, read, written or deleted (much like filemon; ``Filemon's timestamping feature will show you precisely when every open, read, write or delete, happens, and its status column tells you the outcome."), we can write a simple patch that makes a note of these events on the VFS layer, and then we could export this information to userspace, via relayfs. It wouldn't be too hard to code a relatively efficient implementation.

Hareesh

#6 lore raw
Quoted 2 lines · Wei Hu

Yeah, that's basically what I'm looking for.
So is it correct that I can keep track of all the actions as inotify events?

Yes, you can. I just looked at the defn of sys_open and I see that

	fsnotify_open(f->f_dentry);
gets called, which internally calls:
	inotify_dentry_parent_queue_event(...) and,
	inotify_inode_queue_event(...)

Do check out inotify. The same applies to other generic operations on the VFS layer.

Hareesh

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#8 lore raw
Quoted 3 lines

It looks to me like you could use an LD_PRELOAD'ed library to monitor such events?

That's a good idea.
Is there an existing tool, or do I need to write a system call wrapper?

Quoted 3 lines

Alternatively, consider something like the honeynet monitoring kernel monitor module, perhaps.

Could you give more information here?
I'm not familiar with honeynet, thanks.

Quoted 3 lines

Rogan