2009-09-18 20:45:44 +02:00
|
|
|
#!/bin/sh
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
|
2009-11-05 19:26:54 +01:00
|
|
|
# **********************************************************************
|
|
|
|
# Pandora FMS Agent Daemon launcher for Unix (AIX, HP-UX, SunOS, Linux)
|
|
|
|
# (c) 2008-2009 Artica ST
|
|
|
|
# (c) 2008-2009 Sancho Lerena <slerena@gmail.com>
|
|
|
|
#
|
|
|
|
# Please see http://www.pandorafms.org
|
|
|
|
# v3.0 Build 091103
|
|
|
|
# This code is licensed under GPL 2.0 license.
|
|
|
|
# **********************************************************************
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
|
|
|
|
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
|
|
|
|
PANDORA_PATH=/etc/pandora
|
|
|
|
DAEMON=/usr/bin/pandora_agent
|
|
|
|
LOGFILE=/var/log/pandora_agent.log
|
|
|
|
|
2009-11-05 19:26:54 +01:00
|
|
|
# This function replace pidof, not working in the same way in different linux distros
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
|
2009-11-05 19:26:54 +01:00
|
|
|
pidof_pandora () {
|
|
|
|
COLUMNS=300
|
|
|
|
OS_NAME=`uname -s`
|
|
|
|
if [ $OS_NAME = "HP-UX" ]
|
|
|
|
then
|
|
|
|
PANDORA_PID=`ps -ex | grep "$DAEMON $PANDORA_PATH" | grep -v grep | head -1 | awk '{ print $1 }'`
|
|
|
|
else
|
|
|
|
PANDORA_PID=`ps -Af | grep "$DAEMON $PANDORA_PATH" | grep -v grep | head -1 | awk '{ print $2 }'`
|
|
|
|
fi
|
|
|
|
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
echo $PANDORA_PID
|
2009-09-18 20:45:44 +02:00
|
|
|
}
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
|
|
|
|
if [ ! -f $DAEMON ]
|
|
|
|
then
|
|
|
|
echo "Pandora FMS Agent not found at $DAEMON, please check setup"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
PANDORA_PID=`pidof_pandora`
|
|
|
|
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 &
|
2009-11-05 19:26:54 +01:00
|
|
|
rm nohup.out 2> /dev/null
|
|
|
|
sleep 2
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
PANDORA_PID=`pidof_pandora`
|
|
|
|
echo "Pandora FMS Agent is now running with PID $PANDORA_PID"
|
|
|
|
;;
|
|
|
|
|
|
|
|
stop)
|
|
|
|
PANDORA_PID=`pidof_pandora`
|
|
|
|
if [ -z "$PANDORA_PID" ]
|
|
|
|
then
|
|
|
|
echo "Pandora FMS Agent is not running, cannot stop it. Aborting now..."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Stopping Pandora Agent."
|
|
|
|
kill $PANDORA_PID > /dev/null 2>&1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
status)
|
|
|
|
PANDORA_PID=`pidof_pandora`
|
|
|
|
if [ -z "$PANDORA_PID" ]
|
|
|
|
then
|
|
|
|
echo "Pandora FMS Agent is not running."
|
|
|
|
else
|
|
|
|
echo "Pandora FMS Agent is running with PID $PANDORA_PID."
|
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
force-reload|restart)
|
|
|
|
$0 stop
|
|
|
|
sleep 2
|
|
|
|
$0 start
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
2009-11-05 19:26:54 +01:00
|
|
|
echo "Uso: /etc/init.d/pandora_agent_daemon {start|stop|restart|status}"
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|