Bug#283875: [Pkg-nagios-devel] Bug#283875: nagios reload fails too

Olaf van der Spek Olaf van der Spek <OvdSpek@LIACS.NL>, 283875@bugs.debian.org
Thu, 02 Dec 2004 16:44:22 +0100


sean finney wrote:
> hey olaf,
> 
> On Thu, Dec 02, 2004 at 03:56:39PM +0100, Olaf van der Spek wrote:
> 
>>Hmm, now it happened again:
> 
> 
> d'oh.
> 
> 
>>+ '[' -f /var/run/nagios/nagios.pid ']'
>>++ cat /var/run/nagios/nagios.pid
>>+ kill -CHLD 2247
>>+ return 1
>>+ echo 'Not running.'
>>Not running.
>>+ exit 0
>>debian:/etc/init.d# ps aux|grep nagios
>>nagios    2247  0.0  0.5   3316  1420 ?        SNs  11:53   0:02 
>>/usr/sbin/nagios /etc/nagios/nagios.cfg
> 
> 
> so it looks like it got the pid right, but the method for checking
> whether or not nagios is running seems a little sketchy.  try replacing
> the part in your init script that looks like this:
> 
> 
>>    elif [ -f $PIDFILE ]; then
>>        # Try discovering if nagios is alive checking its pid
>>        if kill -CHLD $( cat $PIDFILE ) ; then
>>            return 1    # Isn't started
>>        else
>>            return 0    # Is started
>>        fi
> 
> 
> with this:
> 
>     elif [ -f $PIDFILE ]; then
>         # Try discovering if nagios is alive checking its pid
>         pid=`cat $PIDFILE`
>         if [ "$pid" ]; then
>                 if ps $pid >/dev/null; then
>                         return 0    # Is started
>                 fi
>         else
>             return 1    # Isn't started
>         fi
> 
> i'm not a signal expert, but i don't think sending a kill -CHLD to
> a process is the most reliable way to determine if it's alive. 

That appears to work.
However, I was wondering, why don't you let start-stop-daemon do the 
work of figuring that out and just delete check_started() completely?

> 
> 	sean
> 


-- 
Olaf van der Spek
http://xccu.sf.net/