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

* pandora_server, pandora_network, pandora_recon:
        Added pidof checking to check the PID of the process.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@746 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
marostegui 2008-03-11 15:55:35 +00:00
parent dddc80bee2
commit 5cfd5b4353
4 changed files with 54 additions and 68 deletions

View File

@ -1,3 +1,8 @@
2008-03-11 Manuel Arostegui <marostegui@artica.es>
* pandora_server, pandora_network, pandora_recon:
Added pidof checking to check the PID of the process.
2008-03-06 Sancho Lerena <slerena@gmail.com>
* conf/pandora_server.conf: New tokens for the new servers.

View File

@ -7,7 +7,7 @@
# Configurable path and filenames
PANDORA_HOME="/etc/pandora/pandora_server.conf"
PANDORA_PID_PATH="/var/run/pandora"
PANDORA_PID_PATH="/var/run"
PANDORA_PID=$PANDORA_PID_PATH/pandora_network.pid
PANDORA_DAEMON=/usr/local/bin/pandora_network
@ -28,44 +28,37 @@ fi
case "$1" in
start)
OLD_PATH="`pwd`"
if [ -f $PANDORA_PID ]
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
if [ ! -z $PANDORA_PID ]
then
CHECK_PID=`cat $PANDORA_PID`
CHECK_PID_RESULT=`ps aux | grep -v grep | grep "$CHECK_PID" | grep "pandora_network" | wc -l`
if [ $CHECK_PID_RESULT == 1 ]
then
echo "Pandora FMS Network Server is currently running on this machine with PID ($CHECK_PID). Aborting now..."
exit
fi
echo "Pandora FMS Network Server is currently running on this machine with PID ($PANDORA_PID). Aborting now..."
exit 1
else
rm -f $PANDORA_PID
fi
$PANDORA_DAEMON $PANDORA_HOME -D
sleep 1
MYPID=`ps aux | grep "$PANDORA_DAEMON" | grep -v grep | tail -1 | awk '{ print $2 }'`
if [ ! -z "$MYPID" ]
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
if [ ! -z "$PANDORA_PID" ]
then
echo $MYPID > $PANDORA_PID
echo "Pandora Network Server is now running with PID $MYPID"
echo "Pandora Network Server is now running with PID $PANDORA_PID"
else
echo "Cannot start Pandora FMS Network Server. Aborted."
fi
cd "$OLD_PATH"
;;
stop)
if [ -f $PANDORA_PID ]
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
if [ -z $PANDORA_PID ]
then
echo "Stopping Pandora FMS Network Server"
PID_2=`cat $PANDORA_PID`
if [ ! -z "`ps -F -p $PID_2 | grep -v grep | grep 'pandora_network' `" ]
then
kill `cat $PANDORA_PID` 2> /dev/null > /dev/null
else
echo "Pandora FMS Network Server is not executing with PID $PID_2, skip Killing step"
fi
rm -f $PANDORA_PID
else
echo "Pandora FMS Network Server is not running, cannot stop it."
exit 1
else
echo "Stopping Pandora FMS Network Server"
kill $PANDORA_PID > /dev/null 2>&1
rm -f $PANDORA_PID
fi
;;
force-reload|restart)

View File

@ -7,7 +7,7 @@
# Configurable path and filenames
PANDORA_HOME="/etc/pandora/pandora_server.conf"
PANDORA_PID_PATH="/var/run/pandora"
PANDORA_PID_PATH="/var/run"
PANDORA_PID=$PANDORA_PID_PATH/pandora_recon.pid
PANDORA_DAEMON=/usr/local/bin/pandora_recon
@ -28,42 +28,35 @@ fi
case "$1" in
start)
OLD_PATH="`pwd`"
if [ -f $PANDORA_PID ]
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
if [ ! -z $PANDORA_PID ]
then
CHECK_PID=`cat $PANDORA_PID`
CHECK_PID_RESULT=`ps aux | grep -v grep | grep "$CHECK_PID" | grep "pandora_recon" | wc -l`
if [ $CHECK_PID_RESULT == 1 ]
then
echo "Pandora FMS Recon Server is currently running on this machine with PID ($CHECK_PID). Aborting now..."
exit
fi
echo "Pandora FMS Recon Server is currently running on this machine with PID ($PANDORA_PID). Aborting now..."
exit 1
fi
$PANDORA_DAEMON $PANDORA_HOME -D
sleep 1
MYPID=`ps aux | grep "$PANDORA_DAEMON" | grep -v grep | tail -1 | awk '{print $2}'`
if [ ! -z "$MYPID" ]
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
if [ ! -z "$PANDORA_PID" ]
then
echo $MYPID > $PANDORA_PID
echo "Pandora Recon Server is now running with PID $MYPID"
echo "Pandora Recon Server is now running with PID $PANDORA_PID"
else
echo "Cannot start Pandora FMS Recon Server. Aborted."
fi
cd "$OLD_PATH"
;;
stop)
if [ -f $PANDORA_PID ]
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
if [ -z $PANDORA_PID ]
then
echo "Stopping Pandora FMS Recon Server"
PID_2=`cat $PANDORA_PID`
if [ ! -z "`ps -F -p $PID_2 | grep -v grep | grep 'pandora_recon' `" ]
then
kill `cat $PANDORA_PID` 2> /dev/null > /dev/null
fi
rm -f $PANDORA_PID
else
echo "Pandora FMS Recon Server is not running, cannot stop it."
exit 1
else
echo "Stopping Pandora FMS Recon Server"
kill $PANDORA_PID > /dev/null 2>&1
rm -f $PANDORA_PID
fi
;;
force-reload|restart)

View File

@ -7,7 +7,7 @@
# Configurable path and filenames
PANDORA_HOME="/etc/pandora/pandora_server.conf"
PANDORA_PID_PATH="/var/run/pandora"
PANDORA_PID_PATH="/var/run"
PANDORA_PID=$PANDORA_PID_PATH/pandora_dataserver.pid
PANDORA_DAEMON=/usr/local/bin/pandora_server
@ -28,42 +28,37 @@ fi
case "$1" in
start)
OLD_PATH="`pwd`"
if [ -f $PANDORA_PID ]
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
if [ ! -z $PANDORA_PID ]
then
CHECK_PID=`cat $PANDORA_PID`
CHECK_PID_RESULT=`ps aux | grep -v grep | grep "$CHECK_PID" | grep "pandora_server" | wc -l`
if [ $CHECK_PID_RESULT == 1 ]
then
echo "Pandora FMS Data Server is currently running on this machine with PID ($CHECK_PID). Aborting now..."
exit
fi
echo "Pandora FMS Data Server is currently running on this machine with PID ($PANDORA_PID). Aborting now..."
exit 1
else
rm -f $PANDORA_PID
fi
$PANDORA_DAEMON $PANDORA_HOME -D
sleep 1
MYPID=`ps aux | grep "$PANDORA_DAEMON" | grep -v grep | tail -1 | awk '{print $2}'`
if [ ! -z "$MYPID" ]
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
if [ ! -z "$PANDORA_PID" ]
then
echo $MYPID > $PANDORA_PID
echo "Pandora Data Server is now running with PID $MYPID"
echo "Pandora Data Server is now running with PID $PANDORA_PID"
else
echo "Cannot start Pandora FMS Data Server. Aborted."
fi
cd "$OLD_PATH"
;;
stop)
if [ -f $PANDORA_PID ]
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
if [ -z $PANDORA_PID ]
then
echo "Stopping Pandora FMS Data Server"
PID_2=`cat $PANDORA_PID`
if [ ! -z "`ps -F -p $PID_2 | grep -v grep | grep 'pandora_server' `" ]
then
kill `cat $PANDORA_PID` 2> /dev/null > /dev/null
fi
rm -f $PANDORA_PID
else
echo "Pandora FMS Data Server is not running, cannot stop it."
exit 1
else
echo "Stopping Pandora FMS Data Server"
kill $PANDORA_PID > /dev/null 2>&1
rm -f $PANDORA_PID
fi
;;
force-reload|restart)