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
if [ "$ZONE" = "global" ]
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
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
elif [ "$OS_NAME" = "Linux" ] && [ -x /usr/sbin/vzpid ]
then
@ -66,7 +66,7 @@ pidof_pandora () {
fi
done
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
echo $PANDORA_PID
@ -90,7 +90,14 @@ case "$1" in
su $PANDORA_USER -c "PATH=$PATH nohup $DAEMON $PANDORA_PATH >/dev/null 2>$LOGFILE &"
sleep 2
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)