Please note that LinuxExchange will be shutting down on December 31st, 2016. Visit this thread for additional information and to provide feedback.

Greetings:

I am using Nagios to monitor a host. If the host looses connectivity, I want Nagios to execute an event handler.

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.

While troubleshooting I tried the following as root:

su nagios

./test-handler [and my args here of course]

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:

[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$

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.

Any takers?

asked 07 May '10, 05:08

micheal's gravatar image

micheal
111
accept rate: 0%

1

Is your command a shell script? Do you make assumptions in said script about what your environment looks like? Specifically, do you rely on $PATH to find your programs? I don't know for sure how nagios does it but if it runs the script with a clean environment then that would be a definite difference between running it yourself and letting nagios run it.

(14 May '10, 10:40) sorpigal



Is your script executable?

link

answered 07 May '10, 06:02

mkosmo's gravatar image

mkosmo
1
accept rate: 0%

Yes. And it is executable by user nagios. Refer to my original post "./test-handler".

(07 May '10, 13:20) micheal

Best bet is give it /bin/bash test-handler instead of letting it find the interpreter.

link

answered 01 Jun '10, 14:05

Wayne's gravatar image

Wayne
1
accept rate: 0%

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.

link

answered 23 Jul '10, 14:21

Bob%201's gravatar image

Bob 1
1
accept rate: 0%

Was your issue ever solved? I have a similar issue with Nagios. Here is my command definition:

define command{

    command_name    dlg_notifications
    command_line    /usr/local/nagios/libexec/nagios-msg-broker.sh
    }

and service definition

define service{

   use                             mypc
   service_description             dlg_Alerts_notifications
   check_command                   dlg_notifications
   max_check_attempts              1
   retain_status_information       0
   retain_nonstatus_information    0
   }

/bin/bash /usr/local/nagios/libexec/nagios-msg-broker.sh runs fine manually.

Service defined above can’t run it though. Here are the ownership/permissions of the script:

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

Thanks.

link

answered 30 Mar '12, 13:57

lesman's gravatar image

lesman
112
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×4
×2
×1

Asked: 07 May '10, 05:08

Seen: 7,188 times

Last updated: 30 Mar '12, 13:57

powered by OSQA