Handle forked processes from the init script.

(cherry picked from commit e027ad571f)
This commit is contained in:
Ramon Novoa 2015-04-22 11:11:20 +02:00
parent 50ef10bf72
commit 225cbfb240
1 changed files with 11 additions and 4 deletions

View File

@ -47,9 +47,9 @@ pidof_pandora () {
fi fi
if [ "$ZONE" = "global" ] if [ "$ZONE" = "global" ]
then then
PANDORA_PID=`ps -f -z global | grep "$TRUNCATED_DAEMON" | grep -v grep | head -1 | awk '{ print $2 }'` PANDORA_PID=`ps -f -z global | grep "$TRUNCATED_DAEMON" | grep -v grep | awk '{ print $2 }'`
else else
PANDORA_PID=`ps -Af | grep "$TRUNCATED_DAEMON" | grep -v grep | head -1 | awk '{ print $2 }'` PANDORA_PID=`ps -Af | grep "$TRUNCATED_DAEMON" | grep -v grep | awk '{ print $2 }'`
fi fi
elif [ "$OS_NAME" = "Linux" ] && [ -x /usr/sbin/vzpid ] elif [ "$OS_NAME" = "Linux" ] && [ -x /usr/sbin/vzpid ]
then then
@ -66,7 +66,7 @@ pidof_pandora () {
fi fi
done done
else else
PANDORA_PID=`ps -Af | grep "$DAEMON $PANDORA_PATH" | grep -v grep | head -1 | awk '{ print $2 }'` PANDORA_PID=`ps -Af | grep "$DAEMON $PANDORA_PATH" | grep -v grep | awk '{ print $2 }'`
fi fi
echo $PANDORA_PID echo $PANDORA_PID
@ -90,7 +90,14 @@ case "$1" in
su $PANDORA_USER -c "PATH=$PATH nohup $DAEMON $PANDORA_PATH >/dev/null 2>$LOGFILE &" su $PANDORA_USER -c "PATH=$PATH nohup $DAEMON $PANDORA_PATH >/dev/null 2>$LOGFILE &"
sleep 2 sleep 2
PANDORA_PID=`pidof_pandora` PANDORA_PID=`pidof_pandora`
echo "Pandora FMS Agent is now running with PID $PANDORA_PID" if [ "$PANDORA_PID" = "" ]
then
echo "Pandora FMS Agent could not be started. Please check the file $LOGFILE."
exit 1
else
echo "Pandora FMS Agent is now running with PID $PANDORA_PID"
fi
;; ;;
stop) stop)