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>

View File

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