First, make sure auditd is installed, on RHEL5, I would do:
- yum install audit
Next, let's set up the rule file the follow in terms of what kind of calls we want to monitor for by:
- sudo vim /etc/audit/audit.rules
You rule file should look like the following. In the example below, I want to monitor the filemonitorme in /var/ so I set up a monitor that looks for writes and attribute changes. This will tell me what process touched the file, but sometimes I would want to know what was the argument to that process. You can get a log of all processes using the line immediately above by setting a watch on execve call.
# This file contains the auditctl rules that are loaded
# whenever the audit daemon is started via the initscripts.
# The rules are simply the parameters that would be passed
# to auditctl.
# First rule - delete all
-D
# Increase the buffers to survive stress events.
# Make this bigger for busy systems
-b 2000
# Feel free to add below this line. See auditctl man page
-a always,exit -S execve
-w /var/monitorme -p wa
Now you are ready to start auditd.
- sudo /etc/init.d/auditd restart (invokes both stop and start)
- sudo less /var/log/audit/audit.log
- watch -n 1 "ps -ef >> ~/pslog"