I want to use inotify to monitor /sys/class/net//operstate to detect status of a iface in real time. when I ifdown && ifup eth3, the content of operstate changed, but the file's Modify time didn't change. I don't know the reason, is there any file which can be monitored by inotify to get iface status in real time? Much appreciation for any advice!
below are my terminal msg: [root@yingjie-4-5-0-20201109195739-1 11:10:39 0000:00:0c.0]$stat /sys/class/net/eth3/operstate File: ‘/sys/class/net/eth3/operstate’ Size: 4096 Blocks: 0 IO Block: 4096 regular file Device: 14h/20d Inode: 25838 Links: 1 Access: (0444/-r--r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2020-11-10 20:42:18.592000969 +0800 Modify: 2020-11-10 20:42:18.592000969 +0800 Change: 2020-11-10 20:42:18.592000969 +0800 Birth: - [root@yingjie-4-5-0-20201109195739-1 11:10:50 0000:00:0c.0]$cat /sys/class/net/eth3/operstate up You have new mail in /var/spool/mail/root [root@yingjie-4-5-0-20201109195739-1 11:11:06 0000:00:0c.0]$ifdown eth3 [root@yingjie-4-5-0-20201109195739-1 11:11:13 0000:00:0c.0]$cat /sys/class/net/eth3/operstate down [root@yingjie-4-5-0-20201109195739-1 11:11:16 0000:00:0c.0]$stat /sys/class/net/eth3/operstate File: ‘/sys/class/net/eth3/operstate’ Size: 4096 Blocks: 0 IO Block: 4096 regular file Device: 14h/20d Inode: 25838 Links: 1 Access: (0444/-r--r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2020-11-10 20:42:18.592000969 +0800 Modify: 2020-11-10 20:42:18.592000969 +0800 Change: 2020-11-10 20:42:18.592000969 +0800 Birth: -