Monitor log in realtime, and run a command on a particular event
I think I could probably create a python script to do this, but I wanted to see if someone has been here before me.
We already have a crude working script that "greps" logs searching for a particular event.
The event can easily be identified. The event contains a filename and filepath.
The script then performs a "chattr" on that file.
The script runs once ever 5 mins.
However we now need it to run in real time so as soon as the event occurs the script is triggered.
Responses
That's what logwatch is for. A LOTTA people tie it to fail2ban to enhance system security. Realistically, it can be tied to nearly anything you want to trigger on. Also, the various syslog implementations can support logging to a pipe/script so that you don't have to do any kind of supplemental file-grepping.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
