2009-11-11 Sancho Lerena <slerena@artica.es>
* tentacle_proxy: Upgrade to support a previous check of connectiviy before trying to copy nothing to up server. * generic_daemon_launcher: A generic script used to launch other apps/scripts as daemons. Could be used with tentacle_proxy, daemon_watchdog a secondary pandora_agent or pandora_server instance, for example. * daemon_watchdog: A script used to watchdog for another process, for example a pandora_server or a mysql. This also try to "restart" the process if it's down and has a custom execution field to notify directly admin when a daemon is not restarting and it's down. * build_rpm_packages.sh: Some fixes in RPM build script. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2105 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
7e766b77f1
commit
b397f82423
|
@ -1,3 +1,19 @@
|
|||
2009-11-11 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* tentacle_proxy: Upgrade to support a previous check of connectiviy
|
||||
before trying to copy nothing to up server.
|
||||
|
||||
* generic_daemon_launcher: A generic script used to launch other
|
||||
apps/scripts as daemons. Could be used with tentacle_proxy, daemon_watchdog
|
||||
a secondary pandora_agent or pandora_server instance, for example.
|
||||
|
||||
* daemon_watchdog: A script used to watchdog for another process, for
|
||||
example a pandora_server or a mysql. This also try to "restart" the process
|
||||
if it's down and has a custom execution field to notify directly admin
|
||||
when a daemon is not restarting and it's down.
|
||||
|
||||
* build_rpm_packages.sh: Some fixes in RPM build script.
|
||||
|
||||
2009-09-08 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* Initial load of extras subdir. Expect to have some dirty
|
||||
|
|
|
@ -1,35 +1,43 @@
|
|||
#!/bin/bash
|
||||
|
||||
CODEHOME=/home/slerena/code/pandora/trunk
|
||||
CODEHOME_ENT=/home/slerena/code/artica/code/
|
||||
# YOU NEED TO ALTER THIS PATHS for match paths of your system
|
||||
|
||||
# CONFIG BEGINS HERE
|
||||
CODEHOME=~/code/pandora/trunk
|
||||
CODEHOME_ENT=~/code/artica/code/
|
||||
RPMHOME=/usr/src/rpm
|
||||
VERSION=3.0.0
|
||||
|
||||
# CONFIG ENDS HERE
|
||||
|
||||
echo "Creating source tarballs (/usr/src/rpm/SOURCES)"
|
||||
rm -Rf /usr/src/rpm/SOURCES/pandorafms_*.tar.gz
|
||||
rm -Rf $RPMHOME=/SOURCES/pandorafms_*.tar.gz
|
||||
|
||||
cd $CODEHOME/pandora_agents
|
||||
sudo tar zcvf $RPMHOME/SOURCES/pandorafms_agent-3.0.0.tar.gz --exclude \.svn --exclude nohup linux
|
||||
sudo tar zcvf $RPMHOME/SOURCES/pandorafms_agent-$VERSION.tar.gz --exclude \.svn --exclude nohup linux
|
||||
sudo tar zvcf $RPMHOME/SOURCES/pandorafms_agent_unix-$VERSION.tar.gz --exclude \.svn --exclude nohup unix
|
||||
|
||||
cd $CODEHOME
|
||||
sudo tar zcvf $RPMHOME/SOURCES/pandorafms_server-3.0.0.tar.gz --exclude \.svn pandora_server
|
||||
sudo tar zcvf $RPMHOME/SOURCES/pandorafms_server-$VERSION.tar.gz --exclude \.svn pandora_server
|
||||
|
||||
# Console OpenSource
|
||||
cd $CODEHOME
|
||||
tar zcvf $RPMHOME/SOURCES/pandorafms_console-3.0.0.tar.gz --exclude \.svn --exclude config.php --exclude enterprise pandora_console
|
||||
tar zcvf $RPMHOME/SOURCES/pandorafms_console-$VERSION.tar.gz --exclude \.svn --exclude config.php --exclude enterprise pandora_console
|
||||
# Console Enterprise
|
||||
cd $CODEHOME_ENT/pandora/trunk/pandora_console
|
||||
sudo tar zcvf $RPMHOME/SOURCES/pandorafms_console_enterprise-3.0.0.tar.gz --exclude \.svn --exclude tree_view* enterprise/*
|
||||
sudo tar zcvf $RPMHOME/SOURCES/pandorafms_console_enterprise-$VERSION.tar.gz --exclude \.svn enterprise/*
|
||||
# Server OpenSource
|
||||
cd $CODEHOME_ENT/pandora/trunk/pandora_server/
|
||||
sudo tar zcvf $RPMHOME/SOURCES/pandorafms_server_enterprise-3.0.0.tar.gz --exclude \.svn PandoraFMS-Enterprise
|
||||
sudo tar zcvf $RPMHOME/SOURCES/pandorafms_server_enterprise-$VERSION.tar.gz --exclude \.svn PandoraFMS-Enterprise
|
||||
# Updatemanager Client keygen
|
||||
cd $CODEHOME_ENT/updatemanager/keygen
|
||||
sudo tar cvzf $RPMHOME/SOURCES/pandorafms_keygen-1.0.0.tar.gz --exclude .svn --exclude keygen --exclude keygen.i386.static --exclude pandora_keygen.spec pandora
|
||||
|
||||
sudo tar cvzf $RPMHOME/SOURCES/pandorafms_keygen-$VERSION.tar.gz --exclude .svn --exclude keygen --exclude keygen.i386.static --exclude pandora_keygen.spec pandora
|
||||
|
||||
echo "Creating RPMs at $RPMHOME/RPMS"
|
||||
cd $CODEHOME
|
||||
sudo rpmbuild -ba pandora_console/pandora_console.spec
|
||||
sudo rpmbuild -ba pandora_agents/linux/pandora_agent.spec
|
||||
sudo rpmbuild -ba pandora_agents/unix/pandora_agent.spec
|
||||
sudo rpmbuild -ba pandora_server/pandora_server.spec
|
||||
sudo rpmbuild -ba $CODEHOME_ENT/pandora/trunk/pandora_console/enterprise/pandora_console_enterprise.spec
|
||||
sudo rpmbuild -ba $CODEHOME_ENT/pandora/trunk/pandora_server/PandoraFMS-Enterprise/pandora_server_enterprise.spec
|
||||
|
|
|
@ -0,0 +1,116 @@
|
|||
#!/bin/bash
|
||||
# Copyright (c) 2005-2009 Artica ST
|
||||
# Author: Sancho Lerena <slerena@artica.es> 2009
|
||||
# Licence: GPL2
|
||||
#
|
||||
# daemon_watchdog
|
||||
#
|
||||
# Generic watchdog to detect if a daemon is running. If cannot restart, execute
|
||||
# a custom-user defined command to notify daemon is down and continues in
|
||||
# standby (without notifying / checking) until daemon is alive again.
|
||||
|
||||
# Default configuration is for Pandora FMS Server daemon
|
||||
|
||||
# =====================================================================
|
||||
# Configuration begins here. Please use "" if data contain blank spaces
|
||||
|
||||
export DAEMON_WATCHDOG=daemon_watchdog
|
||||
# DAEMON_WATCHDOG: Name of this script. Used to check if its running already
|
||||
|
||||
export DAEMON_CHECK="/usr/local/bin/pandora_server /etc/pandora/pandora_server.conf"
|
||||
# DAEMON_CHECK: Daemon monitored, please use full path and parameters like
|
||||
# are shown doing a ps aux of ps -Alf
|
||||
|
||||
export DAEMON_RESTART="/etc/init.d/pandora_server restart"
|
||||
# DAEMON_RESTART: Command to try to restart the daemon
|
||||
|
||||
export DAEMON_DEADWAIT=30
|
||||
# DAEMON_DEADWAIT: Time this script checks after detect that
|
||||
# daemon is down before to consider is really down. This
|
||||
|
||||
export DAEMON_ALERT="echo 'XXXXX is down. Please do something!' | mail mymail@gmail.com"
|
||||
# DAEMON_ALERT: Command/Script executed if after detecting daemon is down,
|
||||
# and waiting DAEMON_DEADWAIT, and daemon continues down.
|
||||
|
||||
export DAEMON_LOOP=7
|
||||
# DAEMON_LOOP: Interval within daemon_wathdog checks if daemon is alive.
|
||||
# DO NOT use values under 3-5 seconds or could be CPU consuming.
|
||||
# NEVER NEVER NEVER use 0 value or gets 100% CPU!.
|
||||
|
||||
# Configuration stop here
|
||||
# =====================================================================
|
||||
|
||||
# Check if another instance of this script
|
||||
|
||||
RUNNING_CHECK=`ps aux | grep "$DAEMON_WATCHDOG" | grep -v grep |wc -l`
|
||||
if [ "$RUNNING_CHECK" != "2" ]
|
||||
then
|
||||
echo "Aborting, seems that there are more '$DAEMON_WATCHDOG' running in this system"
|
||||
logger $DAEMON_WATCHDOG aborted execution because another watchdog seems to be running
|
||||
exit -1
|
||||
fi
|
||||
|
||||
|
||||
# This value always must be 0 at start. Do not alter
|
||||
export DAEMON_STANDBY=0
|
||||
|
||||
# This function replace pidof, not working in the same way in different linux distros
|
||||
function pidof_daemon () (
|
||||
# This sets COLUMNS to XXX chars, because if command is run
|
||||
# in a "strech" term, ps aux don't report more than COLUMNS
|
||||
# characters and this will not work.
|
||||
COLUMNS=300
|
||||
DAEMON_PID=`ps aux | grep "$DAEMON_CHECK" | grep -v grep | tail -1 | awk '{ print $2 }'`
|
||||
echo $DAEMON_PID
|
||||
)
|
||||
|
||||
# Main script
|
||||
|
||||
if [ ! -f `echo $DAEMON_CHECK | awk '{ print $1 }'` ]
|
||||
then
|
||||
echo "Daemon you want to check is not present in the system. Aborting watchdog"
|
||||
exit
|
||||
fi
|
||||
|
||||
while [ 1 ]
|
||||
do
|
||||
|
||||
DAEMON_PID=`pidof_daemon`
|
||||
if [ -z "$DAEMON_PID" ]
|
||||
then
|
||||
|
||||
if [ $DAEMON_STANDBY == 0 ]
|
||||
then
|
||||
|
||||
# Daemon down, first detection
|
||||
# Restart it !
|
||||
|
||||
logger $DAEMON_WATCHDOG restarting $DAEMON_CHECK
|
||||
$DAEMON_RESTART 2> /dev/null > /dev/null
|
||||
|
||||
# Just WAIT another DAEMON_DEADWAIT before consider it DEAD
|
||||
|
||||
sleep $DAEMON_DEADWAIT
|
||||
DAEMON_PID=`pidof_daemon`
|
||||
|
||||
if [ -z "$DAEMON_PID" ]
|
||||
then
|
||||
|
||||
# Is dead and can't be restarted properly. Execute alert
|
||||
|
||||
logger $DAEMON_WATCHDOG $DAEMON_CHECK is dead, alerting !
|
||||
$DAEMON_ALERT 2> /dev/null > /dev/null
|
||||
|
||||
# Watchdog process puts in STANDBY mode until process get alive again
|
||||
logger $DAEMON_WATCHDOG "Entering in Stabdby mode"
|
||||
|
||||
DAEMON_STANDBY=1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
DAEMON_STANDBY=0
|
||||
fi
|
||||
|
||||
sleep $DAEMON_LOOP
|
||||
done
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
#!/bin/sh
|
||||
|
||||
# **********************************************************************
|
||||
# Generic Daemon launcher for Unix (AIX, HP-UX, SunOS, Linux)
|
||||
# (c) 2008-2009 Artica ST
|
||||
# (c) 2008-2009 Sancho Lerena <slerena@gmail.com>
|
||||
# This code is licensed under GPL 2.0 license.
|
||||
# **********************************************************************
|
||||
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
|
||||
DAEMON="/home/slerena/code/pandora/trunk/extras/daemon_watchdog"
|
||||
|
||||
# This function replace pidof, not working in the same way in different linux distros
|
||||
|
||||
pidof_daemon () {
|
||||
COLUMNS=300
|
||||
OS_NAME=`uname -s`
|
||||
if [ $OS_NAME = "HP-UX" ]
|
||||
then
|
||||
A_PID=`ps -ex | grep "$DAEMON" | grep -v grep | head -1 | awk '{ print $1 }'`
|
||||
else
|
||||
A_PID=`ps -Af | grep "$DAEMON" | grep -v grep | head -1 | awk '{ print $2 }'`
|
||||
fi
|
||||
|
||||
echo $A_PID
|
||||
}
|
||||
|
||||
if [ ! -f $DAEMON ]
|
||||
then
|
||||
echo "$DAEMON not found, please check setup. Exiting"
|
||||
exit
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
A_PID=`pidof_daemon`
|
||||
if [ ! -z "$A_PID" ]
|
||||
then
|
||||
echo "$DAEMON is currently running on this machine with PID $A_PID"
|
||||
echo "Cannot launch again. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
nohup $DAEMON 2> /dev/null > /dev/null &
|
||||
sleep 2
|
||||
rm nohup.out 2> /dev/null
|
||||
|
||||
A_PID=`pidof_daemon`
|
||||
if [ -z "$A_PID" ]
|
||||
then
|
||||
echo "Cannot start $DAEMON. Exitting"
|
||||
exit 1
|
||||
else
|
||||
echo "$DAEMON is now running with PID $A_PID"
|
||||
fi
|
||||
;;
|
||||
|
||||
stop)
|
||||
A_PID=`pidof_daemon`
|
||||
if [ -z "$A_PID" ]
|
||||
then
|
||||
echo "$DAEMON is not running, cannot stop it. Aborting now..."
|
||||
exit 1
|
||||
else
|
||||
echo "Stopping $DAEMON"
|
||||
kill $A_PID > /dev/null 2>&1
|
||||
fi
|
||||
;;
|
||||
|
||||
status)
|
||||
A_PID=`pidof_daemon`
|
||||
if [ -z "$A_PID" ]
|
||||
then
|
||||
echo "$DAEMON is not running."
|
||||
else
|
||||
echo "$DAEMON is running with PID $A_PID."
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
|
||||
force-reload|restart)
|
||||
$0 stop
|
||||
sleep 2
|
||||
$0 start
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Uso: generic_daemon_launcher {start|stop|restart|status}"
|
||||
exit 1
|
||||
esac
|
||||
|
|
@ -16,12 +16,19 @@ SERVER_IP=192.168.50.1
|
|||
while [ 1 ]
|
||||
do
|
||||
|
||||
for myfile in `find /var/spool/pandora/data_in -type f`
|
||||
do
|
||||
tentacle_client -q -a $SERVER_IP $myfile
|
||||
rm -Rf $myfile
|
||||
# Check before if I can connect to remote IP
|
||||
CAN_CONNECT=`ping -c 1 -q $SERVER_IP | grep " 0%" | wc -l`
|
||||
if [ "$CAN_CONNECT" == 1 ]
|
||||
then
|
||||
|
||||
done
|
||||
for myfile in `find /var/spool/pandora/data_in -type f`
|
||||
do
|
||||
|
||||
tentacle_client -q -a $SERVER_IP $myfile
|
||||
rm -Rf $myfile
|
||||
|
||||
done
|
||||
fi
|
||||
sleep $TIMEOUT
|
||||
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue