2007-06-12 Manuel Arostegui <marostegui@artica.es>

* linux/contrib/pandora_agent_installer: Changed a PATH
          to adapt the script to the 1.3 version.

        * linux/contrib/pandora_agent_daemon: Added nohup.

        * linux/pandora_agent: Added features like:
          Maximum and Minimum hours where the agent can run between.
          Delayed startup for the agent.
          Added NICE option to protect CPU.
          Added "local" as a new transfer mode.

        * linux/pandora_agent.conf: Changed in order to adapt it
          to the new features of the agent.

        * aix/pandora_agent_installer: Added to repository:
          Pandora Agent Installer for AIX Systems.

        * aix/pandora_agent_daemon: Added nohup and fixed a small
          bug related with an "exit" in the beggining of the script.

        * aix/pandora_agent.conf: Changed in order to adapt it
          to the new features of the agent.

        * aix/pandora_agent.sh: Added features like:
          Maximum and Minimum hours where the agent can run between.
          Delayed startup for the agent.
          Added NICE option to protect CPU.
          Added "ftp" and "local" as a new transfer mode.
          Added the chance of choosing the remote ssh port to use.

        * win32/bin/pandora_agent.conf: Changed version number.

        * solaris/pandora_agent_installer: Added to repository:
          Pandora Agent Installer for Solaris Systems.

        * solaris/pandora_agent_daemon: Added nohup.

        * solaris/pandora_agent.conf: Changed in order to adapt it
          to the new features of the agent.

        * solaris/pandora_agent.sh: Added the banner in the start
          up.
          Added features like:
          Maximum and Minimum hours where the agent can run between.
          Delayed startup for the agent.
          Added NICE option to protect CPU.
          Added "ftp" and "local" as a new transfer mode.
          Added the chance of choosing the remote ssh port to use.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@503 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
marostegui 2007-06-12 09:32:54 +00:00
parent 7e25051712
commit 0d2da504d1
14 changed files with 705 additions and 40 deletions

View File

@ -1,3 +1,54 @@
2007-06-12 Manuel Arostegui <marostegui@artica.es>
* linux/contrib/pandora_agent_installer: Changed a PATH
to adapt the script to the 1.3 version.
* linux/contrib/pandora_agent_daemon: Added nohup.
* linux/pandora_agent: Added features like:
Maximum and Minimum hours where the agent can run between.
Delayed startup for the agent.
Added NICE option to protect CPU.
Added "local" as a new transfer mode.
* linux/pandora_agent.conf: Changed in order to adapt it
to the new features of the agent.
* aix/pandora_agent_installer: Added to repository:
Pandora Agent Installer for AIX Systems.
* aix/pandora_agent_daemon: Added nohup and fixed a small
bug related with an "exit" in the beggining of the script.
* aix/pandora_agent.conf: Changed in order to adapt it
to the new features of the agent.
* aix/pandora_agent.sh: Added features like:
Maximum and Minimum hours where the agent can run between.
Delayed startup for the agent.
Added NICE option to protect CPU.
Added "ftp" and "local" as a new transfer mode.
Added the chance of choosing the remote ssh port to use.
* win32/bin/pandora_agent.conf: Changed version number.
* solaris/pandora_agent_installer: Added to repository:
Pandora Agent Installer for Solaris Systems.
* solaris/pandora_agent_daemon: Added nohup.
* solaris/pandora_agent.conf: Changed in order to adapt it
to the new features of the agent.
* solaris/pandora_agent.sh: Added the banner in the start
up.
Added features like:
Maximum and Minimum hours where the agent can run between.
Delayed startup for the agent.
Added NICE option to protect CPU.
Added "ftp" and "local" as a new transfer mode.
Added the chance of choosing the remote ssh port to use.
2007-04-23 Manuel Arostegui <marostegui@artica.es>
* linux/contrib/pandora_agent_installer: Removed an unnecessary

View File

@ -9,9 +9,31 @@ server_ip 192.168.50.1
server_path /var/spool/pandora/data_in
pandora_path /usr/share/pandora_agent
temporal /var/spool/pandora/data_out
interval 300
checksum 0
debug 0
interval 300
checksum 0
debug 1
# By default is 22 (for ssh)
#server_port 22
# ftp, ssh or local
transfer_mode ssh
# delayed_startup defines number of MINUTES before start execution
# for first time when startup Pandora Agent
delayed_startup 90
#Pandora nice defines priority of execution. Less priority means more intensive execution
#A recommended value is 10. 0 priority means no Pandora CPU protection enabled
pandora_nice 10
# min_hour, defines mininum valid hour to allow Pandora agent execution
min_hour 9
# max_hour, defines maximum valid hour to allow Pandora agent execution
max_hour 18
# Module Definition
# =================
@ -69,3 +91,4 @@ module_name mem_free
module_type generic_data
module_exec vmstat | tail -1 | awk '{ print $4 }'
module_end

View File

@ -1,4 +1,4 @@
#!/usr/bin/ksh
#!/usr/bin/ksh
# **********************************************************************
# Pandora Agent for AIX
# v1.2
@ -7,7 +7,7 @@
# This code is licenced under GPL 2.0 licence or later
# **********************************************************************
AGENT_VERSION="1.2 Beta2"
AGENT_VERSION="1.3"
OLDIFS=$IFS
# Stupid trick to use IFS in AIX ... doesnt work standard $'\n' :-?
@ -22,7 +22,7 @@ then
echo " "
echo "FATAL ERROR: I need an argument to PANDORA AGENT home path"
echo " "
echo " example: /usr/share/pandora_ng/pandora_agent.sh /usr/share/pandora_ng "
echo " example: /usr/share/pandora_agent/pandora_agent.sh /etc/pandora "
echo " "
exit
else
@ -42,7 +42,11 @@ echo "$TIMESTAMP - Reading general config parameters from .conf file" >> $PANDOR
# Default values
DEBUG_MODE=0
CHECKSUM_MODE=0
MIN_HOUR=0
MAX_HOUR=0
DELAYED_STARTUP=0
PANDORA_NICE=0
TRANSFER_MODE=ssh
IFS=$NEWIFS
for a in `cat $PANDORA_HOME/pandora_agent.conf | grep -v "^#" | grep -v "^module" `
do
@ -83,8 +87,72 @@ do
CHECKSUM_MODE=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - Checksum mode is $CHECKSUM_MODE " >> $PANDORA_HOME/pandora.log
fi
if [ ! -z "`echo $a | grep -e '^transfer_mode'`" ]
then
TRANSFER_MODE=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - Transfer Mode is $TRANSFER_MODE" >> $PANDORA_LOGFILE
fi
if [ ! -z "`echo $a | grep -e '^min_hour'`" ]
then
MIN_HOUR=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - MIN_HOUR is $MIN_HOUR" >> $PANDORA_LOGFILE
fi
if [ ! -z "`echo $a | grep -e '^max_hour'`" ]
then
MAX_HOUR=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - MAX_HOUR is $MAX_HOUR" >> $PANDORA_LOGFILE
fi
if [ ! -z "`echo $a | grep -e '^delayed_startup'`" ]
then
DELAYED_STARTUP=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - DELAYED_STARTUP is $DELAYED_STARTUP" >> $PANDORA_LOGFILE
fi
# CPU protection
if [ ! -z "`echo $a | grep -e '^pandora_nice'`" ]
then
PANDORA_NICE=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - PandoraFMS Nice is $PANDORA_NICE" >> $PANDORA_LOGFILE
fi
done
# Make some checks
if [ "$TRANSFER_MODE" = "ftp" ]
then
if [ ! -f $HOME/.netrc ]
then
echo "(EE) Transfer mode is FTP but there is no usable .netrc file. Aborting."
exit
fi
fi
if [ "$DEBUG_MODE" = "1" ]
then
echo "(**) Warning: Running in DEBUG mode"
fi
if [ $DELAYED_STARTUP != 0 ]
then
echo "Delayed startup in $DELAYED_STARTUP minutes "
echo "Delayed startup in $DELAYED_STARTUP minutes" >> $PANDORA_LOGFILE.err
echo " "
sleep $(($DELAYED_STARTUP*60))
fi
while [ 1 ]
do
# Check for an appropiate time to execute (5min intervals)
if [ $MAX_HOUR != $MIN_HOUR ]
CURRENT_HOUR=`date +"%H"`
then
while [ $CURRENT_HOUR -lt $MIN_HOUR ] || [ $CURRENT_HOUR -gt $MAX_HOUR ]
do
echo "Waiting to valid time ($MIN_HOUR - $MAX_HOUR, current $CURRENT_HOUR)"
echo "Waiting to valid time ($MIN_HOUR - $MAX_HOUR, current $CURRENT_HOUR)" >> $PANDORA_LOGFILE.err
sleep 300
done
fi
# MAIN Program loop begin
# OS Data
@ -239,15 +307,36 @@ do
echo "NO MD5 CHECKSUM AVAILABLE" > $CHECKSUM
fi
# Send packets to server and delete it
scp $PANDORA_FILES pandora@$SERVER_IP:$SERVER_PATH"
if [ "$DEBUG_MODE" = 1 ]
then
echo "$TIMESTAMP - DEBUG :Copying $PANDORA_FILES to $SERVER_IP:$SERVER_PATH" >> $PANDORA_HOME/pandora.log
else
#scp $PANDORA_FILES pandora@$SERVER_IP:$SERVER_PATH
#if [ "$DEBUG_MODE" = 1 ]
#then
# echo "$TIMESTAMP - DEBUG :Copying $PANDORA_FILES to $SERVER_IP:$SERVER_PATH" >> $PANDORA_HOME/pandora.log
# else
# Send packets to server and detele it
if [ "$TRANSFER_MODE" = "ssh" ]
then
scp -P $SERVER_PORT $PANDORA_FILES pandora@$SERVER_IP:$SERVER_PATH > /dev/null 2> $PANDORA_LOGFILE.err
fi
if [ "$TRANSFER_MODE" = "ftp" ]
then
ftp SERVER_IP > /dev/null 2> $PANDORA_LOGFILE.err
fi
if [ "$TRANSFER_MODE" = "local" ]
then
cp $PANDORA_FILES $SERVER_PATH > /dev/null 2> $PANDORA_LOGFILE.err
fi
# Delete data
rm -f $PANDORA_FILES > /dev/null 2> $PANDORA_LOGFILE.err
# Delete it
rm -f $PANDORA_FILES> /dev/null
fi
# Go to bed :-)
sleep $INTERVAL
done
done
# forever!

View File

@ -2,7 +2,7 @@
# Startup Script for Pandora Agent
# Sancho Lerena, <slerena@gmail.com>
# Version para AIX
# v1.2
# v1.3
# DONT USE WITH OPENSSH
@ -11,8 +11,6 @@
# for example: pandora_agent.sh /usr/share/pandora_agent/ &
exit
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
PANDORA_PATH=/usr/share/pandora_agent/
DAEMON=pandora_agent.sh
@ -32,7 +30,7 @@ case "$1" in
echo "Pandora Agent is currently running on this machine. Aborting now..."
exit
fi
$PANDORA_PATH/$DAEMON $PANDORA_PATH >> $PANDORA_PATH/pandora.log & MYPID=$!
nohup $PANDORA_PATH/$DAEMON $PANDORA_PATH >> $PANDORA_PATH/pandora.log & MYPID=$!
echo $MYPID > $PIDFILE
#MYPID=`ps -Alf | grep $DAEMON | grep -v grep | awk '{ print $4 }' | tail -1`
echo $MYPID > $PIDFILE

View File

@ -0,0 +1,156 @@
#!/usr/bin/ksh
# **********************************************************************
# Pandora Enterprise Generic Host Agent Installer
# AIX version
# (c) 2007 Sancho Lerena <slerena@gmail.com>
# Please see http://pandora.sourceforge.net
# this code is licensed under GPL 2.0 license.
# Este codigo esta licenciado bajo la licencia GPL 2.0.
# **********************************************************************
PI_VERSION=1.0
PANDORA_BIN=/usr/bin/pandora_agent.sh
PANDORA_HOME=/usr/share/pandora_agent
PANDORA_TEMP=/var/spool/pandora
PANDORA_CFG=/etc/pandora
PANDORA_LOG=/var/adm/pandora_agent.log
PANDORA_STARTUP=/etc/rc.pandora_agent_daemon
PANDORA_STARTUP_RC=/etc/rc.d/rc2.d/S90pandora_agent
FORCE=0
LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`
MODE=$1
set `id`
if [ $1 != "uid=0(root)" ]
then
echo " "
echo "I need to run as root"
echo " "
exit 1
fi
if [ ! -f "pandora_agent.sh" ]
then
echo " "
echo "You need to place on main distribution directory before install"
echo " "
exit 1
fi
uninstall () {
echo "Removing Pandora Agent..."
rm -Rf $PANDORA_BIN
rm -Rf $PANDORA_TEMP
rm -Rf $PANDORA_CFG
rm -Rf $PANDORA_STARTUP
rm -Rf $PANDORA_HOME
rm -Rf $PANDORA_LOG
echo "Done"
}
install () {
if [ -f $PANDORA_HOME ] && [ "$FORCE" = "0" ]
then
echo "Seems that default dir already exists. Please use --force to"
echo "force installer to install on $PANDORA_HOME"
exit
else
echo "Checking default dir $PANDORA_HOME..."
fi
if [ -f $PANDORA_BIN ] && [ "$FORCE" = "0" ]
then
echo "Seems that $PANDORA_BIN already exists. Please use --force to"
echo "force installer to reinstall overwriting it"
exit
else
echo "Checking Pandora Agent on $PANDORA_BIN...."
fi
# Create directories
echo "Creating Pandora Agent home directory at $PANDORA_HOME ..."
mkdir $PANDORA_HOME
mkdir $PANDORA_TEMP
mkdir $PANDORA_TEMP/data_out
mkdir $PANDORA_CFG
# Create logfile
if [ ! -z "`touch $PANDORA_LOG`" ]
then
echo "Seems to be a problem generating logfile ($PANDORA_LOG) please checkit";
else
echo "Creating logfile at $PANDORA_LOG..."
fi
echo "$LOG_TIMESTAMP Pandora installer has created this file at startup" > $PANDORA_LOG
# Copying agent and securing it
echo "Copying Pandora Agent to $PANDORA_BIN..."
cp pandora_agent.sh $PANDORA_BIN
chmod 700 $PANDORA_BIN
# Copying moduleS
echo "Copying Pandora Agent configuration file to $PANDORA_HOME/pandora_agent.conf..."
cp pandora_agent.conf $PANDORA_HOME
cp pandora_agent.sh $PANDORA_HOME
cp pandora_agent_daemon $PANDORA_HOME
chmod 600 $PANDORA_HOME/pandora_agent.conf
echo "Linking Pandora Agent configuration to $PANDORA_CFG/pandora_agent.conf..."
ln -s $PANDORA_HOME/pandora_agent.conf $PANDORA_CFG
echo "Setting secure permissions and ownership for all Pandora Agent files..."
chown -R root $PANDORA_HOME
chmod -R 600 $PANDORA_TEMP/data_out
chmod 640 $PANDORA_LOG
chgrp 3 $PANDORA_LOG
echo "Linking start-up daemon script at $PANDORA_STARTUP"
ln -s $PANDORA_HOME/pandora_agent_daemon $PANDORA_STARTUP
echo "Linking start-up daemon script at $PANDORA_STARTUP_RC"
ln -s $PANDORA_HOME/pandora_agent_daemon $PANDORA_STARTUP_RC
chown -R root $PANDORA_BIN
echo "Done."
echo " "
echo "You have your startup script ready at $PANDORA_STARTUP"
echo "First you need to copy your public SSH keys ($HOME/.ssh/id_dsa.pub)"
echo "under /home/pandora/.ssh/authorized_keys on your Pandora Server host"
echo "You also need to setup your $PANDORA_CFG/pandora_agent.conf config file"
echo " "
}
help () {
echo " --force-install To force installation if already installed on system "
echo " --install To install Pandora Agent on this system"
echo " --uninstall To uninstall and remove Pandora Agent on this System"
echo " "
}
# Script banner at start
echo " "
echo "Pandora Enterprise Agent Installer $BI_VERSION (c) 2007 Sancho Lerena"
echo "This program is licensed under GPL2 Terms. http://pandora.sourceforge.net"
echo " "
case "$MODE" in
'--force-install')
FORCE=1
install
exit
;;
'--install')
install
exit
;;
'--uninstall')
uninstall
exit
;;
*)
help
esac

View File

@ -37,7 +37,7 @@ case "$1" in
exit
fi
fi
$DAEMON $PANDORA_PATH 2> $LOGFILE & MYPID=$!
nohup $DAEMON $PANDORA_PATH 2> $LOGFILE & MYPID=$!
echo $MYPID > $PIDFILE
echo "Pandora FMS Agent is now running with PID $MYPID"
;;

View File

@ -9,7 +9,7 @@
PI_VERSION=1.0
PANDORA_BIN=/usr/bin/pandora_agent
PANDORA_HOME=/usr/share/pandora
PANDORA_HOME=/usr/share/pandora_agent
PANDORA_TEMP=/var/spool/pandora
PANDORA_CFG=/etc/pandora
PANDORA_LOG=/var/log/pandora_agent.log

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash
# **********************************************************************
# Pandora FMS Generic Host Agent
# GNU/Linux version
@ -39,7 +39,11 @@ IFS=$'\n'
# Default values
CHECKSUM_MODE=1
DEBUG_MODE=0
MIN_HOUR=0
MAX_HOUR=0
DELAYED_STARTUP=0
SERVER_PORT=22
PANDORA_NICE=10
INTERVAL=300
TRANSFER_MODE=ssh
if [ -z "`echo $LANG | grep '\.'`" ]
@ -115,6 +119,27 @@ do
TRANSFER_MODE=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - Transfer Mode is $TRANSFER_MODE" >> $PANDORA_LOGFILE
fi
if [ ! -z "`echo $a | grep -e '^min_hour'`" ]
then
MIN_HOUR=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - MIN_HOUR is $MIN_HOUR" >> $PANDORA_LOGFILE
fi
if [ ! -z "`echo $a | grep -e '^max_hour'`" ]
then
MAX_HOUR=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - MAX_HOUR is $MAX_HOUR" >> $PANDORA_LOGFILE
fi
if [ ! -z "`echo $a | grep -e '^delayed_startup'`" ]
then
DELAYED_STARTUP=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - DELAYED_STARTUP is $DELAYED_STARTUP" >> $PANDORA_LOGFILE
fi
# CPU protection
if [ ! -z "`echo $a | grep -e '^pandora_nice'`" ]
then
PANDORA_NICE=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - PandoraFMS Nice is $PANDORA_NICE" >> $PANDORA_LOGFILE
fi
done
@ -171,6 +196,28 @@ then
echo "(**) Warning: Running in DEBUG mode"
fi
if [ $DELAYED_STARTUP != 0 ]
then
echo "Delayed startup in $DELAYED_STARTUP minutes "
echo "Delayed startup in $DELAYED_STARTUP minutes" >> $PANDORA_LOGFILE.err
echo " "
sleep $(($DELAYED_STARTUP*60))
fi
while [ 1 ]
do
# Check for an appropiate time to execute (5min intervals)
if [ $MAX_HOUR != $MIN_HOUR ]
CURRENT_HOUR=`date +"%H"`
then
while [ $CURRENT_HOUR -lt $MIN_HOUR ] || [ $CURRENT_HOUR -gt $MAX_HOUR ]
do
echo "Waiting to valid time ($MIN_HOUR - $MAX_HOUR, current $CURRENT_HOUR)" >> $PANDORA_LOGFILE.err
sleep 300
done
fi
# MAIN Program loop begin
while [ "1" == "1" ]
@ -323,7 +370,7 @@ do
exit 0
fi
# Send packets to server and detele it
# Send packets to server and delete it
if [ "$TRANSFER_MODE" == "ssh" ]
then
scp -P $SERVER_PORT $PANDORA_FILES pandora@$SERVER_IP:$SERVER_PATH > /dev/null 2> $PANDORA_LOGFILE.err
@ -344,6 +391,6 @@ do
# Go to bed :-)
sleep $INTERVAL
done
done
done
# This runs forever!

View File

@ -34,6 +34,24 @@ checksum 0
# ftp, ssh or local
transfer_mode ssh
# delayed_startup defines number of MINUTES before start execution
# for first time when startup Pandora Agent
delayed_startup 90
#Pandora nice defines priority of execution. Less priority means more intensive execution
#A recommended value is 10. 0 priority means no Pandora CPU protection enabled
pandora_nice 10
# min_hour, defines mininum valid hour to allow Pandora agent execution
min_hour 9
# max_hour, defines maximum valid hour to allow Pandora agent execution
max_hour 14
# Module Definition
# =================

View File

@ -4,14 +4,36 @@
# General Parameters
# ==================
server_ip 192.168.50.100
server_ip 192.168.50.1
server_path /var/spool/pandora/data_in
pandora_path /usr/share/pandora_agent/
temporal /var/spool/pandora/data_out
interval 300
#agent_name satellite_system
checksum 0
debug 1
debug 1
# By default is 22 (for ssh)
#server_port 22
# ftp, ssh or local
transfer_mode ssh
# delayed_startup defines number of MINUTES before start execution
# for first time when startup Pandora Agent
delayed_startup 90
#Pandora nice defines priority of execution. Less priority means more intensive execution
#A recommended value is 10. 0 priority means no Pandora CPU protection enabled
pandora_nice 10
# min_hour, defines mininum valid hour to allow Pandora agent execution
min_hour 9
# max_hour, defines maximum valid hour to allow Pandora agent execution
max_hour 18
# Module Definition
# =================

View File

@ -1,4 +1,4 @@
#!/usr/bin/ksh
#!/usr/bin/ksh
# **********************************************************************
# Pandora Agent for Solaris
# v1.2
@ -7,7 +7,7 @@
# This code is licenced under GPL 2.0 licence or later
# **********************************************************************
AGENT_VERSION="1.2"
AGENT_VERSION="1.3"
OLDIFS=$IFS
# Stupid trick to use IFS in Solaris/AIX ... doesnt work standard $'\n' :-?
@ -22,7 +22,7 @@ then
echo " "
echo "FATAL ERROR: I need an argument to PANDORA AGENT home path"
echo " "
echo " example: /usr/share/pandora_ng/pandora_agent.sh /usr/share/pandora_ng "
echo " example: /usr/share/pandora_agent/pandora_agent.sh /etc/pandora "
echo " "
exit
else
@ -42,6 +42,14 @@ echo "$TIMESTAMP - Reading general config parameters from .conf file" >> $PANDOR
# Default values
DEBUG_MODE=0
CHECKSUM_MODE=0
MIN_HOUR=0
MAX_HOUR=0
DELAYED_STARTUP=0
SERVER_PORT=22
PANDORA_NICE=10
INTERVAL=300
TRANSFER_MODE=ssh
IFS=$NEWIFS
for a in `cat $PANDORA_HOME/pandora_agent.conf | grep -v "^#" | grep -v "^module" `
@ -83,9 +91,74 @@ do
CHECKSUM_MODE=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - Checksum mode is $CHECKSUM_MODE " >> $PANDORA_HOME/pandora.log
fi
done
if [ ! -z "`echo $a | grep '^min_hour'`" ]
then
MIN_HOUR=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - MIN_HOUR is $MIN_HOUR" >> $PANDORA_LOGFILE
fi
if [ ! -z "`echo $a | grep '^max_hour'`" ]
then
MAX_HOUR=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - MAX_HOUR is $MAX_HOUR" >> $PANDORA_LOGFILE
fi
if [ ! -z "`echo $a | grep '^delayed_startup'`" ]
then
DELAYED_STARTUP=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - DELAYED_STARTUP is $DELAYED_STARTUP" >> $PANDORA_LOGFILE
fi
# CPU protection
if [ ! -z "`echo $a | grep '^pandora_nice'`" ]
then
PANDORA_NICE=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - PandoraFMS Nice is $PANDORA_NICE" >> $PANDORA_LOGFILE
fi
# Contribution of daggett
if [ ! -z "`echo $a | grep '^server_port'`" ]
then
SERVER_PORT=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - Server Port is $SERVER_PORT" >> $PANDORA_LOGFILE
fi
# Contribution of daggett
if [ ! -z "`echo $a | grep '^encoding'`" ]
then
ENCODING=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - Encoding is $ENCODING" >> $PANDORA_LOGFILE
fi
if [ ! -z "`echo $a | grep '^transfer_mode'`" ]
then
TRANSFER_MODE=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - Transfer Mode is $TRANSFER_MODE" >> $PANDORA_LOGFILE
fi
done
# Script banner at start
echo "Pandora FMS Agent $AGENT_VERSION (c) Sancho Lerena 2007"
echo "This program is licensed under GPL2 Terms. http://pandora.sf.net"
echo "Running in $NOMBRE_HOST at $TIMESTAMP"
echo " "
if [ $DELAYED_STARTUP != 0 ]
then
echo "Delayed startup in $DELAYED_STARTUP minutes "
echo "Delayed startup in $DELAYED_STARTUP minutes" >> $PANDORA_LOGFILE.err
echo " "
sleep $(($DELAYED_STARTUP*60))
fi
while [ 1 ]
do
# Check for an appropiate time to execute (5min intervals)
if [ $MAX_HOUR != $MIN_HOUR ]
CURRENT_HOUR=`date +"%H"`
then
while [ $CURRENT_HOUR -lt $MIN_HOUR ] || [ $CURRENT_HOUR -gt $MAX_HOUR ]
do
echo "Waiting to valid time ($MIN_HOUR - $MAX_HOUR, current $CURRENT_HOUR)" >> $PANDORA_LOGFILE.err
sleep 300
done
fi
# MAIN Program loop begin
# OS Data
OS_VERSION=`uname -v`
@ -113,6 +186,19 @@ do
CHECKSUM=$TEMP/$NOMBRE_HOST.$SERIAL.checksum
PANDORA_FILES="$TEMP/$NOMBRE_HOST.$SERIAL.*"
DATA2=$TEMP/$NOMBRE_HOST.$SERIAL.data_temp
# Make some checks
if [ "$TRANSFER_MODE" = "ftp" ]
then
if [ ! -f $HOME/.netrc ]
then
echo "(EE) Transfer mode is FTP but there is no usable .netrc file. Aborting."
exit
fi
fi
if [ "$DEBUG_MODE" = "1" ]
then
echo "(**) Warning: Running in DEBUG mode"
fi
# Makes data packet
echo "<agent_data os_name='$OS_NAME' os_version='$OS_VERSION' interval='$INTERVAL' version='$AGENT_VERSION' timestamp='$TIMESTAMP' agent_name='$NOMBRE_HOST'>" > $DATA
@ -212,7 +298,6 @@ do
fi
done
# Count number of agent runs
CONTADOR=`expr $CONTADOR + 1`
# Keep a limit of 100 for overflow reasons
@ -239,15 +324,35 @@ do
echo "NO MD5 CHECKSUM AVAILABLE" > $CHECKSUM
fi
# Send packets to server and delete it
scp $PANDORA_FILES pandora@$SERVER_IP:$SERVER_PATH
if [ "$DEBUG_MODE" = 1 ]
then
echo "$TIMESTAMP - DEBUG :Copying $PANDORA_FILES to $SERVER_IP:$SERVER_PATH" >> $PANDORA_HOME/pandora.log
else
# scp $PANDORA_FILES pandora@$SERVER_IP:$SERVER_PATH
# if [ "$DEBUG_MODE" = 1 ]
# then
# echo "$TIMESTAMP - DEBUG :Copying $PANDORA_FILES to $SERVER_IP:$SERVER_PATH" >> $PANDORA_HOME/pandora.log
# else
# Delete it
rm -f $PANDORA_FILES> /dev/null
fi
# rm -f $PANDORA_FILES> /dev/null
# fi
if [ "$TRANSFER_MODE" = "ssh" ]
then
scp -P $SERVER_PORT $PANDORA_FILES pandora@$SERVER_IP:$SERVER_PATH > /dev/null 2> $PANDORA_LOGFILE.err
fi
if [ "$TRANSFER_MODE" = "ftp" ]
then
ftp SERVER_IP > /dev/null 2> $PANDORA_LOGFILE.err
fi
if [ "$TRANSFER_MODE" = "local" ]
then
cp $PANDORA_FILES $SERVER_PATH > /dev/null 2> $PANDORA_LOGFILE.err
fi
# Delete data
rm -f $PANDORA_FILES> /dev/null 2> $PANDORA_LOGFILE.err
# Go to bed :-)
sleep $INTERVAL
done
done
# forever!

View File

@ -2,7 +2,7 @@
# Startup Script for Pandora Agent
# Sancho Lerena, <slerena@gmail.com>
# Version para Solaris
# v1.2
# v1.3
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
@ -24,7 +24,7 @@ case "$1" in
echo "Pandora Agent is currently running on this machine. Aborting now..."
exit
fi
$PANDORA_PATH/$DAEMON $PANDORA_PATH >> $PANDORA_PATH/pandora.log & MYPID=$!
nohup $PANDORA_PATH/$DAEMON $PANDORA_PATH >> $PANDORA_PATH/pandora.log & MYPID=$!
echo $MYPID > $PIDFILE
echo "Pandora Agent is now running with PID $MYPID"
;;

View File

@ -0,0 +1,156 @@
#!/usr/bin/ksh
# **********************************************************************
# Pandora Enterprise Generic Host Agent Installer
# AIX version
# (c) 2007 Sancho Lerena <slerena@gmail.com>
# Please see http://pandora.sourceforge.net
# this code is licensed under GPL 2.0 license.
# Este codigo esta licenciado bajo la licencia GPL 2.0.
# **********************************************************************
PI_VERSION=1.0
PANDORA_BIN=/usr/bin/pandora_agent.sh
PANDORA_HOME=/usr/share/pandora_agent
PANDORA_TEMP=/var/spool/pandora
PANDORA_CFG=/etc/pandora
PANDORA_LOG=/var/adm/pandora_agent.log
PANDORA_STARTUP=/etc/rc.pandora_agent_daemon
PANDORA_STARTUP_RC=/etc/rc2.d/S90pandora_agent
FORCE=0
LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`
MODE=$1
set `id`
if [ $1 != "uid=0(root)" ]
then
echo " "
echo "I need to run as root"
echo " "
exit 1
fi
if [ ! -f "pandora_agent.sh" ]
then
echo " "
echo "You need to place on main distribution directory before install"
echo " "
exit 1
fi
uninstall () {
echo "Removing Pandora Agent..."
rm -Rf $PANDORA_BIN
rm -Rf $PANDORA_TEMP
rm -Rf $PANDORA_CFG
rm -Rf $PANDORA_STARTUP
rm -Rf $PANDORA_HOME
rm -Rf $PANDORA_LOG
echo "Done"
}
install () {
if [ -f $PANDORA_HOME ] && [ "$FORCE" = "0" ]
then
echo "Seems that default dir already exists. Please use --force to"
echo "force installer to install on $PANDORA_HOME"
exit
else
echo "Checking default dir $PANDORA_HOME..."
fi
if [ -f $PANDORA_BIN ] && [ "$FORCE" = "0" ]
then
echo "Seems that $PANDORA_BIN already exists. Please use --force to"
echo "force installer to reinstall overwriting it"
exit
else
echo "Checking Pandora Agent on $PANDORA_BIN...."
fi
# Create directories
echo "Creating Pandora Agent home directory at $PANDORA_HOME ..."
mkdir $PANDORA_HOME
mkdir $PANDORA_TEMP
mkdir $PANDORA_TEMP/data_out
mkdir $PANDORA_CFG
# Create logfile
if [ ! -z "`touch $PANDORA_LOG`" ]
then
echo "Seems to be a problem generating logfile ($PANDORA_LOG) please checkit";
else
echo "Creating logfile at $PANDORA_LOG..."
fi
echo "$LOG_TIMESTAMP Pandora installer has created this file at startup" > $PANDORA_LOG
# Copying agent and securing it
echo "Copying Pandora Agent to $PANDORA_BIN..."
cp pandora_agent.sh $PANDORA_BIN
chmod 700 $PANDORA_BIN
# Copying moduleS
echo "Copying Pandora Agent configuration file to $PANDORA_HOME/pandora_agent.conf..."
cp pandora_agent.conf $PANDORA_HOME
cp pandora_agent.sh $PANDORA_HOME
cp pandora_agent_daemon $PANDORA_HOME
chmod 600 $PANDORA_HOME/pandora_agent.conf
echo "Linking Pandora Agent configuration to $PANDORA_CFG/pandora_agent.conf..."
ln -s $PANDORA_HOME/pandora_agent.conf $PANDORA_CFG
echo "Setting secure permissions and ownership for all Pandora Agent files..."
chown -R root $PANDORA_HOME
chmod -R 600 $PANDORA_TEMP/data_out
chmod 640 $PANDORA_LOG
chgrp 3 $PANDORA_LOG
echo "Linking start-up daemon script at $PANDORA_STARTUP"
ln -s $PANDORA_HOME/pandora_agent_daemon $PANDORA_STARTUP
echo "Linking start-up daemon script at $PANDORA_STARTUP_RC"
ln -s $PANDORA_HOME/pandora_agent_daemon $PANDORA_STARTUP_RC
chown -R root $PANDORA_BIN
echo "Done."
echo " "
echo "You have your startup script ready at $PANDORA_STARTUP"
echo "First you need to copy your public SSH keys ($HOME/.ssh/id_dsa.pub)"
echo "under /home/pandora/.ssh/authorized_keys on your Pandora Server host"
echo "You also need to setup your $PANDORA_CFG/pandora_agent.conf config file"
echo " "
}
help () {
echo " --force-install To force installation if already installed on system "
echo " --install To install Pandora Agent on this system"
echo " --uninstall To uninstall and remove Pandora Agent on this System"
echo " "
}
# Script banner at start
echo " "
echo "Pandora Enterprise Agent Installer $BI_VERSION (c) 2007 Sancho Lerena"
echo "This program is licensed under GPL2 Terms. http://pandora.sourceforge.net"
echo " "
case "$MODE" in
'--force-install')
FORCE=1
install
exit
;;
'--install')
install
exit
;;
'--uninstall')
uninstall
exit
;;
*)
help
esac

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora FMS Windows Agent
# Version 1.2.0
# Version 1.3.0
# (c) 2006 Esteban Sanchez
# (c) 2006 Artica Soluciones Tecnologicas
# This program is Free Software, you can redistribute it and/or modify it