Page 1 of 1

Nagios Event Handler script not working

Posted: Mon Feb 14, 2022 1:56 am
by joash0809
Hi Nagios Support,

I created an event handler script, to write into a log file every time a service hits critical hard state. I've defined the command of the event handler as shown in the nagios documentation for event handler. However, I'm using the standard macros that already available in nagios. The issue is when event handler is unable to complete and nothing is written in the log file. when i tried to run the script in the backend by manually inputting the variables then it is able to write the output to the log file. attaching the event handler script as well.

Re: Nagios Event Handler script not working

Posted: Mon Feb 14, 2022 5:15 pm
by ssax
The main issue I see with event handler scripts is related to permissions (testing as root and then nagios can't write to the log file) so double-check the permissions on the log file and the executable.

Please confirm that when you're testing that the host/service is meeting these requirements:
- This is the most common reason why it's not kicked off when you expect
Event handlers are executed when a service or host:

Is in a SOFT problem state
Initially goes into a HARD problem state
Initially recovers from a SOFT or HARD problem state
Taken from here:

https://assets.nagios.com/downloads/nag ... dlers.html

Other than that, there is another option in your /usr/local/nagios/etc/nagios.cfg that you can use to set some old nagios environmental macros (you can set to 1 to enable them and restart the nagios process, zero is the default):

Code: Select all

enable_environment_macros=0
Please PM me a copy of your profile.zip, you can download it from Admin > System Profile by clicking the Download Profile button.