Purpose:
You can create a failure script that is executed when AxoSyslog terminates abnormally, that is, when it exits with a non-zero exit code. For example, you can use this script to send an automatic email notification.
Prerequisites:
The failure script must be the following file: /opt/syslog-ng/sbin/syslog-ng-failure
, and must be executable.
To create a sample failure script, complete the following steps.
Steps:
-
Create a file named
/opt/syslog-ng/sbin/syslog-ng-failure
with the following content: -
Make the file executable:
chmod +x /opt/syslog-ng/sbin/syslog-ng-failure
-
Run the following command in the
/opt/syslog-ng/sbin
directory:./syslog-ng --process-mode=safe-background; sleep 0.5; ps aux | grep './syslog-ng' | grep -v grep | awk '{print $2}' | xargs kill -KILL; sleep 0.5; cat /tmp/test.txt
The command starts AxoSyslog in safe-background mode (which is needed to use the failure script) and then kills it. You should see that the relevant information is written into the
/tmp/test.txt
file, for example: -
You should also see messages similar to the following in system syslog. The exact message depends on the signal (or the reason why AxoSyslog stopped):
The failure script should run on every non-zero exit event.