pandorafms/pandora_agents/linux/pandora_agent_daemon

67 lines
1.7 KiB
Plaintext
Raw Normal View History

#!/bin/bash
# Init script for Pandora FMS agent
# Generic GNU/Linux version
# Sancho Lerena, <slerena@gmail.com>
# v1.3
### BEGIN INIT INFO
# Provides: pandora_agent
# Required-Start: $network
# Required-Stop: $network
# Default-Start: S 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start/stop pandora-agent daemon
### END INIT INFO
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
PANDORA_PATH=/etc/pandora
DAEMON=/usr/bin/pandora_agent
PIDFILE=/var/run/pandora_agent.pid
LOGFILE=/var/log/pandora_agent.log
if [ ! -f $DAEMON ]
then
echo "Pandora FMS Agent not found at $DAEMON, please check setup"
exit
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
fi
2007-06-12 Manuel Arostegui <marostegui@artica.es> * linux/contrib/pandora_agent_installer: Changed a PATH to adapt the script to the 1.3 version. * linux/contrib/pandora_agent_daemon: Added nohup. * linux/pandora_agent: Added features like: Maximum and Minimum hours where the agent can run between. Delayed startup for the agent. Added NICE option to protect CPU. Added "local" as a new transfer mode. * linux/pandora_agent.conf: Changed in order to adapt it to the new features of the agent. * aix/pandora_agent_installer: Added to repository: Pandora Agent Installer for AIX Systems. * aix/pandora_agent_daemon: Added nohup and fixed a small bug related with an "exit" in the beggining of the script. * aix/pandora_agent.conf: Changed in order to adapt it to the new features of the agent. * aix/pandora_agent.sh: Added features like: Maximum and Minimum hours where the agent can run between. Delayed startup for the agent. Added NICE option to protect CPU. Added "ftp" and "local" as a new transfer mode. Added the chance of choosing the remote ssh port to use. * win32/bin/pandora_agent.conf: Changed version number. * solaris/pandora_agent_installer: Added to repository: Pandora Agent Installer for Solaris Systems. * solaris/pandora_agent_daemon: Added nohup. * solaris/pandora_agent.conf: Changed in order to adapt it to the new features of the agent. * solaris/pandora_agent.sh: Added the banner in the start up. Added features like: Maximum and Minimum hours where the agent can run between. Delayed startup for the agent. Added NICE option to protect CPU. Added "ftp" and "local" as a new transfer mode. Added the chance of choosing the remote ssh port to use. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@503 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2007-06-12 11:32:54 +02:00
nohup $DAEMON $PANDORA_PATH 2> $LOGFILE & MYPID=$!
echo $MYPID > $PIDFILE
echo "Pandora FMS Agent is now running with PID $MYPID"
;;
stop)
if [ -f $PIDFILE ]
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
;;
force-reload|restart)
$0 stop
$0 start
;;
*)
echo "Uso: /etc/init.d/pandora_agent_daemon {start|stop|restart|force-reload}"
exit 1
esac