Event Handlers Problem

Thomas Beecher tbeecher at localnet.com
Wed May 4 20:02:57 CEST 2005


I am restarting the service after every change, so that's not an issue. 
Learned that the hard way about 6 months ago...;-p

When I change to this:

command_line    /bin/echo "$HOSTNAME$ $HOSTSTATE$" > /tmp/testing

I do get the appropriate variables passed to the temp file. So it would 
appear that the event handler is at least being called, that's one less 
thing to look at!!

This is where I'm at now. If I do this:

/usr/local/nagios/libexec/restart_pm3.pl $HOSTNAME$ $HOSTSTATE$ >> 
/tmp/testing

from a command line, I get the proper output for the script. (normally 
won't be any, but I inserted some for troubleshooting.) If I call this 
from the event_handler, I only get the macro variables, nothing from the 
  script.


Thomas Beecher II
Network Administrator
LocalNet, Inc
tbeecher at localnet.com

Marc Powell wrote:
> 
>>-----Original Message-----
>>From: nagios-users-admin at lists.sourceforge.net [mailto:nagios-users-
>>admin at lists.sourceforge.net] On Behalf Of Thomas Beecher
>>Sent: Wednesday, May 04, 2005 10:57 AM
>>To: nagios-users at lists.sourceforge.net
>>Subject: Re: [Nagios-users] Event Handlers Problem
>>
>>Well, that was a serious brain fart on my part!!
>>
>>I moved the script to /usr/local/nagios/libexec/, and changed
>>checkcommands.cfg to show:
>>
>>define command{
>>         command_name    restart_pm3
>>         command_line    $USER1$/restart_pm3.pl $HOSTNAME$ $HOSTSTATE$
>>         }
>>
>>$USER1$ is defined in resource.cfg as
>>
>>$USER1$=/usr/local/nagios/libexec
>>
>>Permissions on the file are:
>>
>>-rwxr-xr-x  1 nagios   nagios   1701 2005-05-04 10:47 restart_pm3.pl
>>
>>I've changed the ownership to nagios/nagios to prevent any other
>>potential permission issues.
> 
> 
> All Good.
> 
> 
>>This returns the following:
>>
>>[1115221615] HOST ALERT: buftest;DOWN;SOFT;1;Telnet: CRITICAL - Socket
>>timeout after 1 seconds<br>SNMP: CRITICAL: snmpget returned errors: 1
> 
> (
> 
>>  )<br>PING: CRITICAL - Host Unreachable (10.0.2.152)
>>[1115221615] HOST EVENT HANDLER: buftest;DOWN;SOFT;1;restart_pm3
>>[1115221625] HOST ALERT: buftest;DOWN;SOFT;2;Telnet: CRITICAL - Socket
>>timeout after 1 seconds<br>SNMP: CRITICAL: snmpget returned errors: 1
> 
> (
> 
>>  )<br>PING: CRITICAL - Host Unreachable (10.0.2.152)
>>[1115221625] HOST EVENT HANDLER: buftest;DOWN;SOFT;2;restart_pm3
>>[1115221634] HOST ALERT: buftest;DOWN;SOFT;3;Telnet: CRITICAL - Socket
>>timeout after 1 seconds<br>SNMP: CRITICAL: snmpget returned errors: 1
> 
> (
> 
>>  )<br>PING: CRITICAL - Host Unreachable (10.0.2.152)
>>[1115221634] HOST EVENT HANDLER: buftest;DOWN;SOFT;3;restart_pm3
>>
>>It doesn't error out, and seems to call the script, but it still
> 
> doesn't
> 
>>run.
> 
> 
> Did you remember to restart Nagios after making the config changes?
> 
> 
>>I have not tested the script as the Nagios user, however the front of
>>the script is set to dump whatever args get passed to it out to a file
>>before doing anything else, so if it was choking somwhere in the
> 
> script
> 
>>it would still be logged that it ran.
> 
> 
> Testing as the user the script is running as should be done anyway.
> Often times it shows other, less obvious issues like required libraries
> not being readable or executable by that user. I'd also suggest
> simplifying things greatly by making your event handler  --
> 
> command_line    /bin/echo "$HOSTNAME$ $HOSTSTATE$" > /tmp/testing
> 
> Just to make sure that it's getting run (I'm 99% sure that'll work as I
> expect ;) ).
> 
> --
> Marc 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: NEC IT Guy Games.
> Get your fingers limbered up and give it your best shot. 4 great events, 4
> opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
> win an NEC 61 plasma display. Visit http://www.necitguy.com/?r 
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> ::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
> ::: Messages without supporting info will risk being sent to /dev/null



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list