From 225cbfb24083bc594cb81ff7a0835fd23406bb09 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Wed, 22 Apr 2015 11:11:20 +0200 Subject: [PATCH] Handle forked processes from the init script. (cherry picked from commit e027ad571f06b0b74484356e20c8d4a1a7a7778c) --- pandora_agents/unix/pandora_agent_daemon | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pandora_agents/unix/pandora_agent_daemon b/pandora_agents/unix/pandora_agent_daemon index 9b0205ce87..5181132d88 100755 --- a/pandora_agents/unix/pandora_agent_daemon +++ b/pandora_agents/unix/pandora_agent_daemon @@ -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)