2007-05-24 23:14:06 +02:00
|
|
|
#!/bin/bash
|
2006-03-27 05:37:27 +02:00
|
|
|
# Startup script for Pandora SNMP Console
|
|
|
|
# Sancho Lerena, <slerena@gmail.com>
|
2007-05-24 23:14:06 +02:00
|
|
|
# Linux Version(generic)
|
2007-06-04 15:45:35 +02:00
|
|
|
# v1.3 (May/2007)
|
2006-03-27 05:37:27 +02:00
|
|
|
|
|
|
|
# Compatible with NetSNMP 5.1 or higher
|
|
|
|
|
|
|
|
# Configurable path and filenames
|
2007-04-11 Manuel Arostegui <marostegui@artica.es>
* pandora_agents/linux/pandora_agent.conf, pandora_agents.spec: Changed
PATHS to adapt them to the upcoming 1.3 release.
* pandora_agents/bsd-ipso/pandora_agent_daemon, pandora_agent.conf,
pandora_agent.sh: Changed PATHS to adapt them to
the upcoming 1.3 release.
* pandora_agents/aix/pandora_agent_daemon, pandora_agent.conf,
pandora_agent.sh: Changed PATHS to adapt them
to the upcoming 1.3 release.
* pandora_agents/hp-ux/pandora_agent_daemon, pandora_agent.conf,
pandora_agent.sh: Changed PATHS to adapt them
to the upcoming 1.3 release.
* pandora_agents/win32/bin/pandora_agent.conf: Changed PATHS to
adapt them to the upcoming 1.3 release.
* pandora_agents/meta_agent/pandora_agent_sim.sh, pandora_agent_daemon,
pandora_agent_1.conf, pandora_agent_2.conf, pandora_agent_3.conf,
pandora_agent_4.conf, pandora_agent_5.conf: Changed PATHS
to adapt them to the upcoming 1.3 release.
* pandora_agents/solaris/pandora_agent_daemon, pandora_agent.conf,
pandora_agent.sh: Changed PATHS to adapt them to the upcoming
1.3 release.
* pandora_server/pandora_network, pandora_snmpconsole, pandora_server
pandora_recon: Changed PATHS to adapt them to the
upcoming 1.3 release.
* pandora_server/specs/fedoracore5/pandora_server.spec: Changed
PATHS to adapt them to the upcoming 1.3 release.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@418 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2007-04-11 14:52:04 +02:00
|
|
|
PANDORA_HOME="/usr/share/pandora_server"
|
2006-03-27 05:37:27 +02:00
|
|
|
DAEMON_PATH="$PANDORA_HOME/util"
|
|
|
|
DAEMON_LOG="$PANDORA_HOME/log/snmptrapd.log"
|
|
|
|
DAEMON_PID="$PANDORA_HOME/var/snmptrapd.pid"
|
|
|
|
PANDORA_SNMP_PID="$PANDORA_HOME/var/pandora_snmp.pid"
|
|
|
|
|
|
|
|
# Dont touch this call unless you know are doing.
|
|
|
|
DAEMON="$DAEMON_PATH/snmptrapd -t -On -n -a -Lf $DAEMON_LOG -p $DAEMON_PID -F %4y-%02.2m-%l[**]%02.2h:%02.2j:%02.2k[**]%B[**]%N[**]%w[**]%W[**]%q[**]%v\n"
|
|
|
|
|
|
|
|
if [ ! -f $DAEMON_PATH/snmptrapd ]
|
|
|
|
then
|
|
|
|
echo "NetSNMP snmptrapd not found at $DAEMON_PATH/snmptrapd, please check setup and read manual"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
if [ -f $DAEMON_PID ]
|
|
|
|
then
|
|
|
|
echo "NetSNMP Trap daemon is currently running on this machine. Aborting now..."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -f $DAEMON_LOG 2> /dev/null
|
|
|
|
$DAEMON 2> /dev/null
|
|
|
|
sleep 1
|
|
|
|
RESULT="`cat $DAEMON_LOG | grep 'errno 13' 2> /dev/null`"
|
|
|
|
if [ -z "$RESULT" ]
|
|
|
|
then
|
|
|
|
echo "NetSNMP Trap daemon is now running with PID `cat $DAEMON_PID 2> /dev/null`"
|
|
|
|
else
|
|
|
|
echo "NetSNMP cannot open port (udp/162). Please execute as root user"
|
|
|
|
rm -f $DAEMON_PID 2> /dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f $PANDORA_SNMP_PID ]
|
|
|
|
then
|
2007-06-04 15:45:35 +02:00
|
|
|
echo "Pandora FMS SNMP Server is currently running on this machine. Aborting now..."
|
2006-03-27 05:37:27 +02:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $PANDORA_HOME/bin
|
|
|
|
./pandora_snmpconsole.pl $PANDORA_HOME -D
|
|
|
|
MYPID=`ps aux | grep 'pandora_snmpconsole.pl' | grep -v grep | tail -1 | awk '{print $2}'`
|
|
|
|
if [ ! -z "$MYPID" ]
|
|
|
|
then
|
|
|
|
echo $MYPID > $PANDORA_SNMP_PID
|
2007-06-04 15:45:35 +02:00
|
|
|
echo "Pandora FMS SNMP Server is now running with PID $MYPID"
|
2006-03-27 05:37:27 +02:00
|
|
|
else
|
2007-06-04 15:45:35 +02:00
|
|
|
echo "Cannot start Pandora FMS SNMP Server. Aborted"
|
2006-03-27 05:37:27 +02:00
|
|
|
fi
|
|
|
|
cd "$OLD_PATH"
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
if [ -f $DAEMON_PID ]
|
|
|
|
then
|
|
|
|
echo "Stopping NetSNMP Trap daemon"
|
|
|
|
PID_1=`cat $DAEMON_PID`
|
|
|
|
if [ ! -z "`ps -F -p $PID_1 | grep -v grep | grep 'snmptrapd'`" ]
|
|
|
|
then
|
|
|
|
kill -9 `cat $DAEMON_PID 2> /dev/null`
|
|
|
|
fi
|
|
|
|
rm -f $DAEMON_PID 2> /dev/null > /dev/null
|
|
|
|
rm -f $DAEMON_LOG 2> /dev/null > /dev/null
|
|
|
|
else
|
|
|
|
echo "NetSNMP Trap daemon is not running, cannot stop it."
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f $PANDORA_SNMP_PID ]
|
|
|
|
then
|
|
|
|
echo "Stopping Pandora SNMP Console"
|
|
|
|
PID_2=`cat $PANDORA_SNMP_PID`
|
|
|
|
if [ ! -z "`ps -F -p $PID_2 | grep -v grep | grep 'pandora_snmpconsole'`" ]
|
|
|
|
then
|
|
|
|
kill `cat $PANDORA_SNMP_PID` 2> /dev/null > /dev/null
|
|
|
|
fi
|
|
|
|
rm -f $PANDORA_SNMP_PID
|
|
|
|
else
|
2007-06-04 15:45:35 +02:00
|
|
|
echo "Pandora FMS SNMP Console is not running, cannot stop it."
|
2006-03-27 05:37:27 +02:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
force-reload|restart)
|
|
|
|
$0 stop
|
|
|
|
$0 start
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: pandora_snmpconsole {start|stop|restart}"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|