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)
|
2010-05-18 18:09:06 +02:00
|
|
|
# (c) 2008-2010 Artica ST
|
|
|
|
# (c) 2008-2010 Sancho Lerena <slerena@gmail.com>
|
2009-11-05 19:26:54 +01:00
|
|
|
#
|
|
|
|
# Please see http://www.pandorafms.org
|
2010-11-15 11:32:23 +01:00
|
|
|
# v3.2 Build 101115
|
2009-11-05 19:26:54 +01:00
|
|
|
# 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
|
|
|
|
2010-02-10 18:37:48 +01:00
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: pandora_agent
|
|
|
|
# Required-Start: $network
|
|
|
|
# Required-Stop: $network
|
2010-11-15 11:32:23 +01:00
|
|
|
# Default-Start: 2 3 5
|
2010-02-10 18:37:48 +01:00
|
|
|
# Default-Stop: 0 1 6
|
|
|
|
# Short-Description: Startup script daemon for Pandora FMS agent
|
|
|
|
# Description: Startup script daemon for Pandora FMS agent (linux)
|
|
|
|
### END INIT INFO
|
|
|
|
|
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
|
2011-04-11 18:35:45 +02:00
|
|
|
DAEMON_TENTACLE=/usr/bin/tentacle_server
|
2010-05-18 18:09:06 +02:00
|
|
|
LOGFILE=/var/log/pandora/pandora_agent.log
|
2010-12-16 20:34:22 +01:00
|
|
|
PANDORA_USER=root
|
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
|
|
|
# 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 () {
|
2010-05-18 18:09:06 +02:00
|
|
|
COLUMNS=400
|
2009-11-05 19:26:54 +01:00
|
|
|
OS_NAME=`uname -s`
|
|
|
|
if [ $OS_NAME = "HP-UX" ]
|
|
|
|
then
|
2014-08-13 16:53:16 +02:00
|
|
|
PANDORA_PID=`ps -ef | grep "/usr/bin/perl $DAEMON" | grep -v grep | awk '{print $2}'`
|
|
|
|
elif [ "$OS_NAME" = "SunOS" ]
|
|
|
|
then
|
|
|
|
ZONENAME_CMD="/bin/zonename"
|
|
|
|
TRUNCATED_DAEMON=`echo "$DAEMON $PANDORA_PATH" | cut -c1-20`
|
|
|
|
if [ -x $ZONENAME_CMD ]
|
2010-08-17 03:58:46 +02:00
|
|
|
then
|
2014-08-13 16:53:16 +02:00
|
|
|
ZONE=`$ZONENAME_CMD`
|
|
|
|
else
|
|
|
|
ZONE=
|
|
|
|
fi
|
|
|
|
if [ "$ZONE" = "global" ]
|
2011-09-05 11:52:18 +02:00
|
|
|
then
|
2015-04-22 11:11:20 +02:00
|
|
|
PANDORA_PID=`ps -f -z global | grep "$TRUNCATED_DAEMON" | grep -v grep | awk '{ print $2 }'`
|
2010-08-17 03:58:46 +02:00
|
|
|
else
|
2015-04-22 11:11:20 +02:00
|
|
|
PANDORA_PID=`ps -Af | grep "$TRUNCATED_DAEMON" | grep -v grep | awk '{ print $2 }'`
|
2010-08-17 03:58:46 +02:00
|
|
|
fi
|
2014-08-13 16:53:16 +02:00
|
|
|
elif [ "$OS_NAME" = "Linux" ] && [ -x /usr/sbin/vzpid ]
|
|
|
|
then
|
|
|
|
# Virtuozzo/OpenVZ
|
|
|
|
local _pid _ctid _pids
|
|
|
|
_pids=`ps -Af | grep "$DAEMON $PANDORA_PATH" | grep -v grep | awk '{ print $2 }'`
|
|
|
|
[ "$_pids" ] && for _pid in $_pids
|
|
|
|
do
|
|
|
|
_ctid=`/usr/sbin/vzpid $_pid | awk '$1 == '$_pid' { print $2 }'`
|
|
|
|
if [ "X$_ctid" = "X0" ]
|
|
|
|
then
|
|
|
|
PANDORA_PID=$_pid
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
2015-04-22 11:11:20 +02:00
|
|
|
PANDORA_PID=`ps -Af | grep "$DAEMON $PANDORA_PATH" | grep -v grep | awk '{ print $2 }'`
|
2009-11-05 19:26:54 +01:00
|
|
|
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
|
2011-01-27 02:54:34 +01:00
|
|
|
su $PANDORA_USER -c "PATH=$PATH nohup $DAEMON $PANDORA_PATH >/dev/null 2>$LOGFILE &"
|
2009-11-05 19:26:54 +01:00
|
|
|
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`
|
2015-04-22 11:11:20 +02:00
|
|
|
if [ "$PANDORA_PID" = "" ]
|
|
|
|
then
|
|
|
|
|
|
|
|
echo "Pandora FMS Agent could not be started. Please check the file $LOGFILE."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Pandora FMS Agent is now running with PID $PANDORA_PID"
|
|
|
|
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
|
|
|
;;
|
|
|
|
|
|
|
|
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."
|
2011-04-12 17:09:25 +02:00
|
|
|
su $PANDORA_USER -c "kill $PANDORA_PID >/dev/null 2>&1"
|
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
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
status)
|
|
|
|
PANDORA_PID=`pidof_pandora`
|
|
|
|
if [ -z "$PANDORA_PID" ]
|
|
|
|
then
|
|
|
|
echo "Pandora FMS Agent is not running."
|
2013-10-21 10:08:12 +02:00
|
|
|
exit 3
|
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
|
|
|
else
|
|
|
|
echo "Pandora FMS Agent is running with PID $PANDORA_PID."
|
2013-10-21 10:08:12 +02:00
|
|
|
exit 0
|
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
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
force-reload|restart)
|
|
|
|
$0 stop
|
|
|
|
sleep 2
|
|
|
|
$0 start
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
2010-11-15 11:32:23 +01:00
|
|
|
echo "Usage: /etc/init.d/pandora_agent_daemon {start|stop|restart|status}"
|
|
|
|
exit 1
|
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
|
|
|
esac
|
|
|
|
|