2008-03-11 Manuel Arostegui <marostegui@artica.es>

* linux/pandora_agent_daemon: Added pidof checking to
        check the PID of the process.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@742 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
marostegui 2008-03-11 14:20:54 +00:00
parent 1c713a2465
commit 97be85b405
2 changed files with 22 additions and 23 deletions

View File

@ -1,3 +1,7 @@
2008-03-11 Manuel Arostegui <marostegui@artica.es>
* linux/pandora_agent_daemon: Added pidof checking to
check the PID of the process.
2008-02-02 Sancho lerena <slerena@gmail.com> 2008-02-02 Sancho lerena <slerena@gmail.com>

View File

@ -2,7 +2,7 @@
# Init script for Pandora FMS agent # Init script for Pandora FMS agent
# Generic GNU/Linux version # Generic GNU/Linux version
# Sancho Lerena, <slerena@gmail.com> # Sancho Lerena, <slerena@gmail.com>
# v1.3 # v1.3.1
### BEGIN INIT INFO ### BEGIN INIT INFO
# Provides: pandora_agent # Provides: pandora_agent
@ -27,33 +27,28 @@ fi
case "$1" in case "$1" in
start) start)
if [ -f $PIDFILE ] PANDORA_PID=$(pidof -x $DAEMON)
then if [ ! -z "$PANDORA_PID" ]
PID_BA=`cat $PIDFILE` then
if [ ! -z "`ps -Af | awk '{ print $2 }' | grep $PID_BA`" ] echo "Pandora FMS Agent is currently running on this machine with PID $PANDORA_PID"
then echo "Cannot launch again. Aborting."
echo "Pandora FMS Agent is currently running on this machine with PID $PID_BA" exit 1
echo "Cannot launch again. Aborting."
exit
fi
fi fi
nohup $DAEMON $PANDORA_PATH 2> $LOGFILE & MYPID=$! nohup $DAEMON $PANDORA_PATH 2> $LOGFILE & PANDORA_PID=$!
echo $MYPID > $PIDFILE echo $PANDORA_PID > $PIDFILE
echo "Pandora FMS Agent is now running with PID $MYPID" echo "Pandora FMS Agent is now running with PID $PANDORA_PID"
;; ;;
stop) stop)
if [ -f $PIDFILE ] PANDORA_PID=$(pidof -x $DAEMON)
if [ -z "$PANDORA_PID" ]
then then
echo "Stopping Pandora Agent."
PID_2=`cat $PIDFILE`
if [ ! -z "`ps -f -p $PID_2 | grep -v grep | grep 'pandora_agent'`" ]
then
kill -9 $PID_2
fi
rm -f $PIDFILE
else
echo "Pandora FMS Agent is not running, cannot stop it. Aborting now..." echo "Pandora FMS Agent is not running, cannot stop it. Aborting now..."
fi exit 1
else
echo "Stopping Pandora Agent."
kill $PANDORA_PID > /dev/null 2>&1
rm -f $PANDORA_PID
fi
;; ;;
force-reload|restart) force-reload|restart)
$0 stop $0 stop