When SELinux logs an event to the audit log on my CentOS 6 system, it's logging it in epoch time which makes for a real hassle when trying to troubleshoot. Is there any way to make it log these events using human readable date formats? I've looked through the conf files and googled around but can't seem to find anything on it.
Asked
Active
Viewed 1.1k times
3 Answers
4
I don't think there are any configuration options, but I found a script that will prepend human readable times:
egrep '^type=(AVC|SELINUX)' /var/log/audit/audit.log |
while read line; do
time=`echo $line | sed 's/.*audit(\([0-9]*\).*/\1/'`;
echo `date -d @$time` $line;
done
Source: http://blog.commandlinekungfu.com/2010/08/episode-106-epoch-fail.html

Rsaesha
- 360
- 3
- 11
-
Thanks. The script works really well! Also, +1 for quanta's script, which works as well just not as much filtering. I was hoping there was a way to make it just write the normal date format when logging but that doesn't seem to be an available option. – Safado Nov 04 '11 at 17:11
1
You can use sed and date commands to convert datetime then to format it.
tail -f /var/log/audit/audit.log | sed -re 's/(^.+)([0-9]{10})(.+$)/echo "\1"`date -d @\2 +%Y-%m-%d_%H:%M:%S`"\3"/e'
the same using perl:
tail -f /var/log/audit/audit.log | perl -pe 's/(\d{10})/`echo -n \`date -d \@$1 +%Y-%m-%d_%H:%M:%S\``/e'

shmakovpn
- 111
- 2