How to detect changes in /proc/net/ files?

1.6k views Asked by At

I'm looking forward to create a network monitor by looking into the contents of /proc/net folder. It's my specific requirement that I can't do any packet sniffing or anything like that. All my source is /proc/net.For example I can get all the active TCP connection details from /proc/net/tcp etc.

The contents of these files keep on changing, so I want to read these files continuously but also I need to read only when it's contents changes, that is if there is no network connected the file contents won't change and I don't' need to read them.

I looked into inotify but it does not detect the changes in /proc/net/ files.

inotifywatch /proc/net/

Continuous polling I guess will be ineffective. So looking for a suggestion.. Thanks in advance..

1

There are 1 answers