Answers to: Nagios: Event handlers not executing.http://linuxexchange.org/questions/355/nagios-event-handlers-not-executing<p>Greetings:</p> <p>I am using Nagios to monitor a host. If the host looses connectivity, I want Nagios to execute an event handler.</p> <p>The host definition contains a defined event_handler directive. The host inherits from generic-host and; therefore, event_handler_enabled is 1. In my main configuration file event handling is enabled. The associated command configuration file has also been defined.</p> <p>While troubleshooting I tried the following as root:</p> <h1>su nagios</h1> <h1>./test-handler [and my args here of course]</h1> <p>The output is correct as user nagios. However, the nagios binary that runs under user nagios will not execute the script. Here is a bit of my nagios.log file:</p> <p>[1273208210] HOST ALERT: vXP;DOWN;SOFT;2;CRITICAL - Host Unreachable (192.168.0.21) [1273208210] HOST EVENT HANDLER: vXP;(null);(null);(null);test-handler!$HOSTADDRESS$ [1273208212] EXTERNAL COMMAND: SCHEDULE_FORCED_HOST_CHECK;vXP;1273208211 [1273208220] HOST ALERT: vXP;UP;SOFT;3;PING OK - Packet loss = 0%, RTA = 35.37 ms [1273208220] HOST EVENT HANDLER: vXP;(null);(null);(null);test-handler!$HOSTADDRESS$</p> <p>According to the output, nagios appears to be running my command; however, based on the output it is actually doing nothing at all. I know that whatever I'm missing is probably very simple (and knowing me; it's right under my nose), but I'm at a loss.</p> <p>Any takers?</p>enFri, 30 Mar 2012 13:57:12 -0400Answer by lesmanhttp://linuxexchange.org/questions/355/nagios-event-handlers-not-executing/2813<p>Was your issue ever solved? I have a similar issue with Nagios. Here is my command definition:</p> <p>define command{</p> <pre><code> command_name dlg_notifications command_line /usr/local/nagios/libexec/nagios-msg-broker.sh } </code></pre> <p>and service definition</p> <p>define service{</p> <pre><code> use mypc service_description dlg_Alerts_notifications check_command dlg_notifications max_check_attempts 1 retain_status_information 0 retain_nonstatus_information 0 } </code></pre> <p>/bin/bash /usr/local/nagios/libexec/nagios-msg-broker.sh runs fine manually.</p> <p>Service defined above can’t run it though. Here are the ownership/permissions of the script:</p> <p>perfserver-10:/usr/local/nagios/libexec$ ls -l nagios-msg-broker.sh -rwxrwxrwx 1 nagios nagcmd 149 Mar 30 10:04 nagios-msg-broker.sh</p> <p>Thanks.</p>lesmanFri, 30 Mar 2012 13:57:12 -0400http://linuxexchange.org/questions/355/nagios-event-handlers-not-executing/2813Answer by Bob 1http://linuxexchange.org/questions/355/nagios-event-handlers-not-executing/1128<p>Shouldn't that (null);(null);(null); in the log be something like "CRITICAL;HARD;1" -- without those inputs your script won't process anything. Not sure what is preventing those status variables from getting passed/populated.</p>Bob 1Fri, 23 Jul 2010 14:21:54 -0400http://linuxexchange.org/questions/355/nagios-event-handlers-not-executing/1128Answer by Waynehttp://linuxexchange.org/questions/355/nagios-event-handlers-not-executing/752<p>Best bet is give it /bin/bash test-handler instead of letting it find the interpreter.</p>WayneTue, 01 Jun 2010 14:05:00 -0400http://linuxexchange.org/questions/355/nagios-event-handlers-not-executing/752Answer by mkosmohttp://linuxexchange.org/questions/355/nagios-event-handlers-not-executing/356<p>Is your script executable?</p>mkosmoFri, 07 May 2010 06:02:48 -0400http://linuxexchange.org/questions/355/nagios-event-handlers-not-executing/356