Nagios daemon (release 2.0b3) not catching signals as I would exp ect

Ralph.Grothe at itdz-berlin.de Ralph.Grothe at itdz-berlin.de
Tue Aug 2 15:05:32 CEST 2005


Hello,

I already asked in another posting here if Nagios 2.0b3 still
could be considered buggy.
(you may remember)

I'm not sure whether I should send this "observation" to the
developers as a bug report or not.
Besides, I don't reckon AIX 4.3 being regarded a decisive target
platform.
I'm also only unwillingly stuck with this hosting OS for my
Nagios setup.

[nagios at daisy:~/etc]
$ oslevel
4.3.3.0

At least for my gcc 2.95 build of nagios on this platform the
daemon doesn't catch signals as I would expect/wish.

I found that if the running nagios daemon receives a SIGHUP, that
it hangs itself instead of reinitializing after last final words
of

$ grep SIGHUP /var/opt/nagios/log/nagios.log 
[1122984843] Caught SIGHUP, restarting...


Having been sent a second SIGHUP it dies completely.

Similarly sending the running nagios a SIGTERM it also gets hung.
It always requires a second SIGTERM to finish it.


Being more at home on SysV systems like HPUX, Solaris, GNU/Linux
I'm not really into this BSDish "run level" concept (or rather
the lack of such) of AIX, and unaware how IPC is handled there.


I want the nagios daemon be started and halted at system startup
and shutdown.
Thus I wrote the wee SysV inspired RC script below that I would
simply want to source
and issue a "nagios start" or "nagios stop" below.

Are there any quirks (especially with regard to AIX) that I would
have to consider
when starting/stopping/restarting the nagios daemon, or should
the below at least theoretically work?

Rgds.
Ralph


P.S. my supposed way to start/stop nagios:


[nagios at daisy:~/etc]
$ cat nagios_functions.sh 
{
if ! echo $0|grep -q bash; then
    echo "Sorry mate, this script uses Bash syntax but you don't
run Bash"
    return 1
fi
if [[ $(uname -s) != AIX ]]; then
    echo "Sorry, this isn't a multi *nix script and currently
only supports AIX"
    return 1
fi
} 1>&2

nagios_pid() {
    ps -u nagios -o pid=,ppid=,comm=|awk
'$3=="nagios"&&$2==1{print$1}'
}

nagios() {

CHECK=~nagios/libexec/check_nagios
LOG=~nagios/var/log/nagios.log
CFG=~nagios/etc/nagios.cfg
PID=~nagios/var/nagios.pid
BIN=/opt/sw/nagios/bin/nagios

local pid=
if [ -s $PID ] && kill -0 $(cat $PID) 2>/dev/null; then
    pid=$(cat $PID)
fi
(( $pid )) || pid=$(nagios_pid)
case "$1" in 
    check)
	echo "Doing pre-flight check of nagios.cfg"
	$BIN -v $CFG
	;;
    status)
	if $CHECK -F $LOG -e 1 -C $BIN && (( $pid )); then
	    echo
	    ps -o pid,etime,args -p $pid
	fi
	;;
    start)
	if (( $pid )); then
	    echo "There's already a running nagios daemon"
	    ps -o pid,etime,args -p $pid
	    echo "You first have to run \"nagios stop\""
	    return 1
	fi 1>&2
	echo "Starting Nagios as daemon..."
	$BIN -d $CFG
	sleep 5
	echo "Last three lines of $LOG:"
	tail -3 $LOG
	;;
    stop)
	if [[ -z $pid ]]; then
	    echo "There's no Nagios daemon running, nothing to
stop"
	else
	    echo "Sending SIGTERM to Nagios daemon PID $pid"
	    kill $pid
	    typeset -i i=0 s=6
	    while kill -0 $pid && (( i < 10 )); do
		echo "PID $pid still responding, snoozing for
another $s secs"
		sleep $s
		(( i+=1 ))
	    done
	    echo "Last three lines of $LOG:"
	    tail -3 $LOG
	    if kill -0 $pid; then
		echo "Couldn't kill the beast, please send it
SIGKILL" 
		return 1
	    fi 2>&1
	fi
	;;
    graceful)
	if (( $pid )); then
	    echo "Sending Nagios daemon PID $pid a SIGHUP"
	    kill -HUP $pid
	    sleep 5
	    nagios status
	    echo "Last three lines of $LOG:"
	    tail -3 $LOG
	else
	    echo "There was no Nagios daemon running, doing cold
start"
	    nagios start
	fi
	;;
    help|*)
	echo "usage: nagios {check|graceful|start|stop|status}"
	;;
esac
}


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
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