We have an use case that we need to compress a logfile when it is rotated.
More specifically we have the auditd audit trail that is rotated based on size...
So when the size of the logfile reaches 100M it will rotate and the following is added to /var/log/messages
:
Audit daemon rotating log files with keep option
I would like, when this line is logged, that a script is executed that would compress the file audit.log.1
that has been created.
I thought omprog
to be the best way to do this unless there is something better.
the documentation on omprog is not very clear.. is what I want possible with rsyslog or another type of daemon who monitors the filesystem and upon the presence of a file it will trigger a compress script?
logrotate
to rotate your audit logs instead ofauditd
itself. It can compress logs, and signal auditd that the file has changed. It can even run an arbitrary program afterwards.auditd[27134]: Error receiving audit netlink packet (No buffer space available)
logrotate is not an option for me unfortunately. I am checking into python pyinotify that seems to do the trick. the recommended way to rotate auditd.log are by the auditd daemon itself. we had logrotate in place but too many events where lost everytime the log rotated with letting auditd itself to the rotation we doo not lose events. also increasing the buffer in audit.rules doesn't help either.. we put it very high. without success.