diff --git a/pandora_agents/mac_osx/pandora_fms/StartupParameters.plist b/pandora_agents/mac_osx/pandora_fms/StartupParameters.plist new file mode 100644 index 0000000000..2a1c6ae414 --- /dev/null +++ b/pandora_agents/mac_osx/pandora_fms/StartupParameters.plist @@ -0,0 +1,20 @@ + + + + + Description + Pandora FMS Agent 1.3 (Mac) + OrderPreference + None + Provides + + PandoraFMS + + Uses + + Network + Resolver + + + + diff --git a/pandora_agents/mac_osx/pandora_fms/pandora_fms b/pandora_agents/mac_osx/pandora_fms/pandora_fms new file mode 100755 index 0000000000..8e7355b30f --- /dev/null +++ b/pandora_agents/mac_osx/pandora_fms/pandora_fms @@ -0,0 +1,62 @@ +#!/bin/bash +# Init script for Pandora FMS agent +# Generic GNU/Linux version +# (c) Sancho Lerena, +# (c) Evi Vanoost +# v2.0 + +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 + +. /etc/rc.common + +StartService() +{ + 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 + + nohup $DAEMON $PANDORA_PATH 2> $LOGFILE & MYPID=$! + echo $MYPID > $PIDFILE + echo "Pandora FMS Agent is now running with PID $MYPID" +} + +StopService() +{ + 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 +} + +RestartService() +{ + $0 stop + $0 start +} + +RunService "$1"