[Nagiosplug-help] Issues with Remote Event Handling via NRPE

Garrett Honeycutt gh at 3gupload.com
Fri Sep 16 12:20:04 CEST 2005


I am attempting to run an event-handler via nrpe. I wrote a quick test
script
------------------------------------------------
test.sh
#!/bin/bash
wall "arg1 is $1 :: arg2 is $2 :: arg3 is $3"
exit 0
-----------------------------------------------

When I run 'check_nrpe -H janis -c test -a CRITICAL HARD 3' I get "NRPE:
Unable to read output" on the server and the expected results on the
client.

----------------------------------------------------------
Broadcast message from nagios (Fri Sep 16 14:09:01 2005):

arg1 is CRITICAL :: arg2 is HARD :: arg3 is 3
----------------------------------------------------------

When I run 'check_nrpe -H janis -c restart-apache -a CRITICAL HARD 3' I
get "CHECK_NRPE: Error receiving data from daemon." and nothing happens
on the client. 

When su nagios on the client and run the script by
hand, ./restart-apache CRITICAL HARD 3, It works great and restarts
apache. 

Where am I going wrong? I appreciate your help and have included all the
pertinent data below.

Thanks
-g



[ nrpe was rebuilt as follows ]


./configure --with-nrpe-user=nagios --with-nrpe-group=nagios
--with-nrpe-port=5666 --enable-ssl --enable-command-args

I copied the src/check_nrpe to my libexec directory and I scp'd src/nrpe
to janis:/usr/sbin/

[ misccommands.cfg ]

define command{
    command_name    restart-apache
    command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c
restart-apache -a $SERVICESTATE$ $STATETYPE$ $SERVICEATTEMPT$
}

[ services.cfg ]

define service {
use		      generic-service
host_name             janis
service_description   apache process
// if there are 0 httpd processes, we have a problem
check_command         check_nrpe!check_apache_proc
event_handler         restart-apache
is_volatile           0
max_check_attempts    3
normal_check_interval 5
retry_check_interval  1
check_period          24x7
notification_interval 60
notification_period   24x7
notification_options  w,c,r
contact_groups        group
}

generic-service DOES have  
event_handler_enabled       1

[ hosts.cfg ] 

generic-host also has
event_handler_enabled       1

[ nagios.cfg ]

log_event_handlers=1
event_handler_timeout=30
enable_event_handlers=1


----------------------------------------------------

[ nrpe.cfg on client contains ]

dont_blame_nrpe=1

command[restart-apache]=/home/nagios/events/restart-apache.sh $ARG1$
$ARG2$ $ARG3$

[ /etc/sudoers ]

nagios      ALL=NOPASSWD: /etc/init.d/apache start, /etc/init.d/apache
stop

[ files ]
[root at janis events]# ls -la
total 16
drwxr-xr-x    2 nagios   nagios       4096 Sep 16 14:07 .
drwx------    4 nagios   nagios       4096 Sep 16 14:02 ..
-rwxr-xr-x    1 nagios   nagios       2455 Sep 16 13:34
restart-apache.sh
-rwxr-xr-x    1 nagios   nagios         58 Sep 16 14:07 test.sh


[ script that runs is as follows ]

#!/bin/bash
case "$1" in
OK)
    ;;
WARNING)
    ;;
UNKNOWN)
    ;;
CRITICAL)
    case "$2" in
    SOFT)
        case "$3" in
        3)
            echo -n "Restarting HTTP service (3rd soft critical
state)..."
                sudo /etc/init.d/apache stop
                sleep 2
                sudo /etc/init.d/apache start
            ;;
            esac
        ;;

    HARD)
        echo -n "Restarting HTTP service..."
        sudo /etc/init.d/apache stop
        sleep 2
        sudo /etc/init.d/apache start
        ;;
    esac
    ;;
esac
exit 0


-- 
// Garrett Honeycutt
// Sr. Systems Administrator
// 3GUpload.com, Inc.
// 317.472.4969 Office





More information about the Help mailing list