I'd like to monitor calls to stat
on any file within a directory. I know inotifywait
can listen for file creation etc. but I don't know anything that can listen for stat
. This is on Amazon Linux 2. Any ideas?
1 Answer
auditd can do that.
man auditd.rules
-> System Call
Example: https://access.redhat.com/solutions/36278
Also consider its alternatives: https://github.com/slackhq/go-audit https://osquery.io/
-
I can't figure out how to restrict this to a specific directory. Closest I got is
auditctl -a always,exit -F arch=b64 -S stat -F dir=/tmp/ooo -k mytest
but that doesn't show any logs. I also tried-w /tmp/ooo
but that doesn't liststat
calls.– JohnnySep 12, 2021 at 14:01 -
You could offer a bounty for the question. I'm not well versed in the topic and it's far behind, so unlikely to be answered. Sep 12, 2021 at 14:04