Event Handler with NRPE - Restart Service Not Working

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Event Handler with NRPE - Restart Service Not Working

Postby mitchsmith » Fri Jul 15, 2011 9:17 am

Hi,

I am developing an EventHandler to restart apache tomcat.

I have a shell script on the host tomcat is run from, that restarts tomcat. This script functions perfectly when executed by the nagios user on this host.

Code: Select all
#!/bin/bash
# /usr/local/nagios/libexec/eventhandlers/restart_tomcat1
#
# SCRIPT TO RESTART TOMCAT CALLED BY NRPE if check_http returns 2 soft Critical Results

/usr/bin/sudo /etc/init.d/tomcat1 stop
logger "TOMCAT1 - AUTO RESTART ATTEMPTED - STOP"

sleep 15
logger "TOMCAT1 - AUTO RESTART ATTEMPTED - WAIT 15sec"

/usr/bin/sudo /etc/init.d/tomcat1 start
logger "TOMCAT1 - AUTO RESTART ATTEMPTED - START"

echo "RESTART ATTEMPT FINISHED"

exit 0


The Logger statements print to /var/log/messages and the tomcat instance successfully restarts.


HOWEVER if I execute the command via NRPE from my nagios server... It Fails.

The script executes and the Logger statments are printed, but nothing happens to the tomcat instance.

My Config is:

I have NRPE configured to accept the command: restartTomcat1
Code: Select all
command[restartTomcat1]=/usr/local/nagios/libexec/eventhandlers/restart_tomcat1


and the nrpe deamon is started and run as user nagios (/etc/xinetd.d/nrpe
Code: Select all
# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
        flags           = REUSE
        socket_type     = stream
        port            = 5666
        wait            = no
        user            = nagios
        group           = nagios
        server          = /usr/local/nagios/bin/nrpe
        server_args     = -c /usr/local/nagios/etc/nrpe.cfg --inetd
        log_on_failure  += USERID
        disable         = no
        only_from       = 127.0.0.1 NAGIOSHOST
}


However when I execute the command
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H MyHOSTAddress -c restartTomcat1 -t 55


I get the logger statements but the TOMCAT Commands to stop and start appear to not execute.

I have added the nagios user to the sudoers file
Code: Select all
nagios ALL=(ALL) NOPASSWD:ALL


Can anyone help me?
mitchsmith
 
Posts: 33
Joined: Mon Apr 04, 2011 7:26 am

Return to Nagios Core

Who is online

Users browsing this forum: Google [Bot], MSN [Bot] and 3 guests