Event Handlers Problem

admin at jpk236.com admin at jpk236.com
Wed May 4 18:05:35 CEST 2005


Thomas,
     Can we see the contents of this perl script you wrote?  Perhaps 
it's a problem within the script?  Thanks.

  - Justin Kulikowski
     [ http://www.jpk236.com ]

Thomas Beecher wrote:
> 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.
> 
> 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.
> 
> 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.
> 
> 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 9:31 AM
>>> To: nagios-users at lists.sourceforge.net
>>> Subject: [Nagios-users] Event Handlers Problem
>>>
>>> I am working with the Nagios event handlers, and I'm coming across a
>>> problem I can't seem to get a handle on.
>>>
>>> I've got a perl script (restart_pm3.pl) that I want to be called as a
>>> host event handler, and pass two macros: $HOSTNAME$ and $HOSTSTATE$.
>>
>>
>> At
>>
>>> present, I have the following set up:
>>>
>>> In hosts.cfg
>>>
>>> define host{
>>>         use             generic-host
>>>         host_name       buftest
>>>         alias           buftest
>>>         address         10.0.2.152
>>>         contact_groups  noc
>>>         event_handler   restart_pm3
>>> }
>>>
>>> In checkcommands.cfg
>>>
>>> define command{
>>>         command_name    restart_pm3
>>>         command_line    /home/tbeecher/test_scripts/restart_pm3.pl
>>> $HOSTNAME$ $HOSTSTATE$
>>> }
>>>
>>>
>>> The Nagios logs show that the even handler is called when the service
>>> checks fail and the host goes down:
>>>
>>> [1115216792] HOST ALERT: buftest;DOWN;HARD;10;Telnet: CRITICAL -
>>
>>
>> Socket
>>
>>> timeout after 1 seconds<br>SNMP: CRITICAL: snmpget returned errors: 1
>>
>>
>> (
>>
>>>  )<br>PING: CRITICAL - Host Unreachable (10.0.2.152)
>>> [1115216792] HOST EVENT HANDLER: buftest;DOWN;HARD;10;restart_pm3
>>>
>>> So far so good right?
>>>
>>> Well, the actual perl script is never executed. I have execute
>>> permissions on it for everyone, and edited it so it logs every time it
>>> is executed, and what ARGVs were passed to it. Works fine when called
>>> manuallt from a command line, but Nagios never calls is. Any insight?
>>
>>
>>
>> On most modern systems, user accounts in /home are only accessible by
>> that user (i.e. tbeecher in your case). Are the permissions on
>> /home/tbeecher such that the nagios user can access the directory? I
>> know you said you tested it from the command line but you didn't specify
>> if your test was run as the nagios user.
>>
>> -- 
>> 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


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