2008-12-10 Ramon Novoa <rnovoa@artica.es>
* linux/pandora_agent, linux/pandora_agent.conf: Added support for a secondary server. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1283 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
1b1a277ff1
commit
7bcf6f642c
|
@ -8,7 +8,7 @@
|
||||||
# **********************************************************************
|
# **********************************************************************
|
||||||
|
|
||||||
AGENT_VERSION=2.0
|
AGENT_VERSION=2.0
|
||||||
AGENT_BUILD=080529
|
AGENT_BUILD=081210
|
||||||
|
|
||||||
# **********************************************************************
|
# **********************************************************************
|
||||||
# function configure_agent()
|
# function configure_agent()
|
||||||
|
@ -25,68 +25,55 @@ function configure_agent {
|
||||||
then
|
then
|
||||||
PANDORA_LOGFILE=`echo $a | awk '{ print $2 }' `
|
PANDORA_LOGFILE=`echo $a | awk '{ print $2 }' `
|
||||||
echo "$TIMESTAMP - [SETUP] - Pandora Logfile is $PANDORA_LOGFILE" >> $PANDORA_LOGFILE
|
echo "$TIMESTAMP - [SETUP] - Pandora Logfile is $PANDORA_LOGFILE" >> $PANDORA_LOGFILE
|
||||||
fi
|
elif [ ! -z "`echo $a | grep -e '^server_ip'`" ]
|
||||||
if [ ! -z "`echo $a | grep -e '^server_ip'`" ]
|
|
||||||
then
|
then
|
||||||
SERVER_IP=`echo $a | awk '{ print $2 }' `
|
SERVER_IP=`echo $a | awk '{ print $2 }' `
|
||||||
echo "$TIMESTAMP - [SETUP] - Server IP Address is $SERVER_IP" >> $PANDORA_LOGFILE
|
echo "$TIMESTAMP - [SETUP] - Server IP Address is $SERVER_IP" >> $PANDORA_LOGFILE
|
||||||
fi
|
elif [ ! -z "`echo $a | grep -e '^server_path'`" ]
|
||||||
if [ ! -z "`echo $a | grep -e '^server_path'`" ]
|
|
||||||
then
|
then
|
||||||
SERVER_PATH=`echo $a | awk '{ print $2 }' `
|
SERVER_PATH=`echo $a | awk '{ print $2 }' `
|
||||||
echo "$TIMESTAMP - [SETUP] - Server Path is $SERVER_PATH" >> $PANDORA_LOGFILE
|
echo "$TIMESTAMP - [SETUP] - Server Path is $SERVER_PATH" >> $PANDORA_LOGFILE
|
||||||
fi
|
elif [ ! -z "`echo $a | grep -e '^temporal'`" ]
|
||||||
if [ ! -z "`echo $a | grep -e '^temporal'`" ]
|
|
||||||
then
|
then
|
||||||
TEMP=`echo $a | awk '{ print $2 }' `
|
TEMP=`echo $a | awk '{ print $2 }' `
|
||||||
echo "$TIMESTAMP - [SETUP] - Temporal Path is $TEMP" >> $PANDORA_LOGFILE
|
echo "$TIMESTAMP - [SETUP] - Temporal Path is $TEMP" >> $PANDORA_LOGFILE
|
||||||
fi
|
elif [ ! -z "`echo $a | grep -e '^interval'`" ]
|
||||||
if [ ! -z "`echo $a | grep -e '^interval'`" ]
|
|
||||||
then
|
then
|
||||||
INTERVAL=`echo $a | awk '{ print $2 }' `
|
INTERVAL=`echo $a | awk '{ print $2 }' `
|
||||||
echo "$TIMESTAMP - [SETUP] - Interval is $INTERVAL seconds" >> $PANDORA_LOGFILE
|
echo "$TIMESTAMP - [SETUP] - Interval is $INTERVAL seconds" >> $PANDORA_LOGFILE
|
||||||
fi
|
elif [ ! -z "`echo $a | grep -e '^agent_name'`" ]
|
||||||
if [ ! -z "`echo $a | grep -e '^agent_name'`" ]
|
|
||||||
then
|
then
|
||||||
NOMBRE_HOST=`echo $a | awk '{ print $2 }' `
|
NOMBRE_HOST=`echo $a | awk '{ print $2 }' `
|
||||||
echo "$TIMESTAMP - [SETUP] - Agent name is $NOMBRE_HOST " >> $PANDORA_LOGFILE
|
echo "$TIMESTAMP - [SETUP] - Agent name is $NOMBRE_HOST " >> $PANDORA_LOGFILE
|
||||||
fi
|
elif [ ! -z "`echo $a | grep -e '^debug'`" ]
|
||||||
if [ ! -z "`echo $a | grep -e '^debug'`" ]
|
|
||||||
then
|
then
|
||||||
DEBUG_MODE=`echo $a | awk '{ print $2 }' `
|
DEBUG_MODE=`echo $a | awk '{ print $2 }' `
|
||||||
echo "$TIMESTAMP - [SETUP] - Debug mode is $DEBUG_MODE " >> $PANDORA_LOGFILE
|
echo "$TIMESTAMP - [SETUP] - Debug mode is $DEBUG_MODE " >> $PANDORA_LOGFILE
|
||||||
fi
|
|
||||||
|
|
||||||
# Contribution of daggett
|
# Contribution of daggett
|
||||||
if [ ! -z "`echo $a | grep -e '^server_port'`" ]
|
elif [ ! -z "`echo $a | grep -e '^server_port'`" ]
|
||||||
then
|
then
|
||||||
SERVER_PORT=`echo $a | awk '{ print $2 }' `
|
SERVER_PORT=`echo $a | awk '{ print $2 }' `
|
||||||
echo "$TIMESTAMP - [SETUP] - Server Port is $SERVER_PORT" >> $PANDORA_LOGFILE
|
echo "$TIMESTAMP - [SETUP] - Server Port is $SERVER_PORT" >> $PANDORA_LOGFILE
|
||||||
fi
|
|
||||||
# Contribution of daggett
|
# Contribution of daggett
|
||||||
if [ ! -z "`echo $a | grep -e '^encoding'`" ]
|
elif [ ! -z "`echo $a | grep -e '^encoding'`" ]
|
||||||
then
|
then
|
||||||
ENCODING=`echo $a | awk '{ print $2 }' `
|
ENCODING=`echo $a | awk '{ print $2 }' `
|
||||||
echo "$TIMESTAMP - [SETUP] - Encoding is $ENCODING" >> $PANDORA_LOGFILE
|
echo "$TIMESTAMP - [SETUP] - Encoding is $ENCODING" >> $PANDORA_LOGFILE
|
||||||
fi
|
elif [ ! -z "`echo $a | grep -e '^transfer_mode'`" ]
|
||||||
if [ ! -z "`echo $a | grep -e '^transfer_mode'`" ]
|
|
||||||
then
|
then
|
||||||
TRANSFER_MODE=`echo $a | awk '{ print $2 }' `
|
TRANSFER_MODE=`echo $a | awk '{ print $2 }' `
|
||||||
echo "$TIMESTAMP - [SETUP] - Transfer Mode is $TRANSFER_MODE" >> $PANDORA_LOGFILE
|
echo "$TIMESTAMP - [SETUP] - Transfer Mode is $TRANSFER_MODE" >> $PANDORA_LOGFILE
|
||||||
fi
|
elif [ ! -z "`echo $a | grep -e '^delayed_startup'`" ]
|
||||||
if [ ! -z "`echo $a | grep -e '^delayed_startup'`" ]
|
|
||||||
then
|
then
|
||||||
DELAYED_STARTUP=`echo $a | awk '{ print $2 }' `
|
DELAYED_STARTUP=`echo $a | awk '{ print $2 }' `
|
||||||
echo "$TIMESTAMP - [SETUP] - DELAYED_STARTUP is $DELAYED_STARTUP" >> $PANDORA_LOGFILE
|
echo "$TIMESTAMP - [SETUP] - DELAYED_STARTUP is $DELAYED_STARTUP" >> $PANDORA_LOGFILE
|
||||||
fi
|
|
||||||
# CPU protection
|
# CPU protection
|
||||||
if [ ! -z "`echo $a | grep -e '^pandora_nice'`" ]
|
elif [ ! -z "`echo $a | grep -e '^pandora_nice'`" ]
|
||||||
then
|
then
|
||||||
PANDORA_NICE=`echo $a | awk '{ print $2 }' `
|
PANDORA_NICE=`echo $a | awk '{ print $2 }' `
|
||||||
echo "$TIMESTAMP - [SETUP] - PandoraFMS Nice is $PANDORA_NICE" >> $PANDORA_LOGFILE
|
echo "$TIMESTAMP - [SETUP] - PandoraFMS Nice is $PANDORA_NICE" >> $PANDORA_LOGFILE
|
||||||
fi
|
|
||||||
# Tentacle options
|
# Tentacle options
|
||||||
if [ ! -z "`echo $a | grep -e '^server_pwd'`" ]
|
elif [ ! -z "`echo $a | grep -e '^server_pwd'`" ]
|
||||||
then
|
then
|
||||||
SERVER_PWD=`echo $a | awk '{ print $2 }' `
|
SERVER_PWD=`echo $a | awk '{ print $2 }' `
|
||||||
if [ ! -z "$SERVER_PWD" ]
|
if [ ! -z "$SERVER_PWD" ]
|
||||||
|
@ -94,8 +81,7 @@ function configure_agent {
|
||||||
TENTACLE_OPTS="-x $SERVER_PWD $TENTACLE_OPTS"
|
TENTACLE_OPTS="-x $SERVER_PWD $TENTACLE_OPTS"
|
||||||
echo "$TIMESTAMP - [SETUP] - Server password set (FTP/Tentacle)" >> $PANDORA_LOGFILE
|
echo "$TIMESTAMP - [SETUP] - Server password set (FTP/Tentacle)" >> $PANDORA_LOGFILE
|
||||||
fi
|
fi
|
||||||
fi
|
elif [ ! -z "`echo $a | grep -e '^server_ssl'`" ]
|
||||||
if [ ! -z "`echo $a | grep -e '^server_ssl'`" ]
|
|
||||||
then
|
then
|
||||||
SERVER_SSL=`echo $a | awk '{ print $2 }' `
|
SERVER_SSL=`echo $a | awk '{ print $2 }' `
|
||||||
if [ "$SERVER_SSL" == "yes" ]
|
if [ "$SERVER_SSL" == "yes" ]
|
||||||
|
@ -103,13 +89,11 @@ function configure_agent {
|
||||||
TENTACLE_OPTS="-c $TENTACLE_OPTS"
|
TENTACLE_OPTS="-c $TENTACLE_OPTS"
|
||||||
echo "$TIMESTAMP - [SETUP] - OpenSSL enabled for Tentacle" >> $PANDORA_LOGFILE
|
echo "$TIMESTAMP - [SETUP] - OpenSSL enabled for Tentacle" >> $PANDORA_LOGFILE
|
||||||
fi
|
fi
|
||||||
fi
|
elif [ ! -z "`echo $a | grep -e '^cron_mode'`" ]
|
||||||
if [ ! -z "`echo $a | grep -e '^cron_mode'`" ]
|
then
|
||||||
then
|
|
||||||
CRON_MODE=1
|
CRON_MODE=1
|
||||||
echo "$TIMESTAMP - [SETUP] - Cronmode enabled" >> $PANDORA_LOGFILE
|
echo "$TIMESTAMP - [SETUP] - Cronmode enabled" >> $PANDORA_LOGFILE
|
||||||
fi
|
elif [ ! -z "`echo $a | grep -e '^server_opts'`" ]
|
||||||
if [ ! -z "`echo $a | grep -e '^server_opts'`" ]
|
|
||||||
then
|
then
|
||||||
SERVER_OPTS=`echo $a | cut -d" " -f2-`
|
SERVER_OPTS=`echo $a | cut -d" " -f2-`
|
||||||
if [ ! -z "$SERVER_OPTS" ]
|
if [ ! -z "$SERVER_OPTS" ]
|
||||||
|
@ -117,15 +101,59 @@ function configure_agent {
|
||||||
TENTACLE_OPTS="$SERVER_OPTS $TENTACLE_OPTS"
|
TENTACLE_OPTS="$SERVER_OPTS $TENTACLE_OPTS"
|
||||||
echo "$TIMESTAMP - [SETUP] - Extra options for the Tentacle client $SERVER_OPTS" >> $PANDORA_LOGFILE
|
echo "$TIMESTAMP - [SETUP] - Extra options for the Tentacle client $SERVER_OPTS" >> $PANDORA_LOGFILE
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
# Remote configuration
|
# Remote configuration
|
||||||
if [ ! -z "`echo $a | grep -e '^remote_config'`" ]
|
elif [ ! -z "`echo $a | grep -e '^remote_config'`" ]
|
||||||
then
|
then
|
||||||
REMOTE_CONFIG=`echo $a | awk '{ print $2 }'`
|
REMOTE_CONFIG=`echo $a | awk '{ print $2 }'`
|
||||||
if [ "$REMOTE_CONFIG" == "1" ]
|
if [ "$REMOTE_CONFIG" == "1" ]
|
||||||
then
|
then
|
||||||
echo "$TIMESTAMP - [SETUP] - Remote configuration enabled" >> $PANDORA_LOGFILE
|
echo "$TIMESTAMP - [SETUP] - Remote configuration enabled" >> $PANDORA_LOGFILE
|
||||||
fi
|
fi
|
||||||
|
# Secondary server configuration
|
||||||
|
elif [ ! -z "`echo $a | grep -e '^secondary_mode'`" ]
|
||||||
|
then
|
||||||
|
SECONDARY_MODE=`echo $a | awk '{ print $2 }' `
|
||||||
|
echo "$TIMESTAMP - [SETUP] - Secondary server mode is '$SECONDARY_MODE'" >> $PANDORA_LOGFILE
|
||||||
|
elif [ ! -z "`echo $a | grep -e '^secondary_transfer_mode'`" ]
|
||||||
|
then
|
||||||
|
SECONDARY_TRANSFER_MODE=`echo $a | awk '{ print $2 }' `
|
||||||
|
echo "$TIMESTAMP - [SETUP] - Secondary transfer Mode is $SECONDARY_TRANSFER_MODE" >> $PANDORA_LOGFILE
|
||||||
|
elif [ ! -z "`echo $a | grep -e '^secondary_server_ip'`" ]
|
||||||
|
then
|
||||||
|
SECONDARY_SERVER_IP=`echo $a | awk '{ print $2 }' `
|
||||||
|
echo "$TIMESTAMP - [SETUP] - Secondary server IP Address is $SECONDARY_SERVER_IP" >> $PANDORA_LOGFILE
|
||||||
|
elif [ ! -z "`echo $a | grep -e '^secondary_server_path'`" ]
|
||||||
|
then
|
||||||
|
SECONDARY_SERVER_PATH=`echo $a | awk '{ print $2 }' `
|
||||||
|
echo "$TIMESTAMP - [SETUP] - Secondary server Path is $SECONDARY_SERVER_PATH" >> $PANDORA_LOGFILE
|
||||||
|
elif [ ! -z "`echo $a | grep -e '^secondary_server_port'`" ]
|
||||||
|
then
|
||||||
|
SECONDARY_SERVER_PORT=`echo $a | awk '{ print $2 }' `
|
||||||
|
echo "$TIMESTAMP - [SETUP] - Secondary server Port is $SECONDARY_SERVER_PORT" >> $PANDORA_LOGFILE
|
||||||
|
elif [ ! -z "`echo $a | grep -e '^secondary_server_pwd'`" ]
|
||||||
|
then
|
||||||
|
SECONDARY_SERVER_PWD=`echo $a | awk '{ print $2 }' `
|
||||||
|
if [ ! -z "$SECONDARY_SERVER_PWD" ]
|
||||||
|
then
|
||||||
|
SECONDARY_TENTACLE_OPTS="-x $SECONDARY_SERVER_PWD $SECONDARY_TENTACLE_OPTS"
|
||||||
|
echo "$TIMESTAMP - [SETUP] - Secondary server password set (FTP/Tentacle)" >> $PANDORA_LOGFILE
|
||||||
|
fi
|
||||||
|
elif [ ! -z "`echo $a | grep -e '^secondary_server_ssl'`" ]
|
||||||
|
then
|
||||||
|
SECONDARY_SERVER_SSL=`echo $a | awk '{ print $2 }' `
|
||||||
|
if [ "$SECONDARY_SERVER_SSL" == "yes" ]
|
||||||
|
then
|
||||||
|
SECONDARY_TENTACLE_OPTS="-c $SECONDARY_TENTACLE_OPTS"
|
||||||
|
echo "$TIMESTAMP - [SETUP] - OpenSSL enabled for secondary Tentacle" >> $PANDORA_LOGFILE
|
||||||
|
fi
|
||||||
|
elif [ ! -z "`echo $a | grep -e '^secondary_server_opts'`" ]
|
||||||
|
then
|
||||||
|
SECONDARY_SERVER_OPTS=`echo $a | cut -d" " -f2-`
|
||||||
|
if [ ! -z "$SERVER_OPTS" ]
|
||||||
|
then
|
||||||
|
SECONDARY_TENTACLE_OPTS="$SECONDARY_SERVER_OPTS $SECONDARY_TENTACLE_OPTS"
|
||||||
|
echo "$TIMESTAMP - [SETUP] - Extra options for the secondary Tentacle client $SECONDARY_SERVER_OPTS" >> $PANDORA_LOGFILE
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -210,6 +238,34 @@ FEOF1
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# **********************************************************************
|
||||||
|
# function send_file_secure(file)
|
||||||
|
# Sends the file to the available server.
|
||||||
|
# **********************************************************************
|
||||||
|
function send_file_secure {
|
||||||
|
FILE="$1"
|
||||||
|
|
||||||
|
send_file "$FILE"
|
||||||
|
RC=$?
|
||||||
|
|
||||||
|
# Always send the file to the secondary server
|
||||||
|
if [ "$SECONDARY_MODE" = "always" ]; then
|
||||||
|
switch_servers
|
||||||
|
send_file "$FILE"
|
||||||
|
switch_servers
|
||||||
|
# Send the file to the secondary server only if something went wrong
|
||||||
|
elif [ "$SECONDARY_MODE" = "on_error" ]; then
|
||||||
|
if [ $RC != 0 ]; then
|
||||||
|
switch_servers
|
||||||
|
send_file "$FILE"
|
||||||
|
RC=$?
|
||||||
|
switch_servers
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
return $RC
|
||||||
|
}
|
||||||
|
|
||||||
# **********************************************************************
|
# **********************************************************************
|
||||||
# function recv_file(file)
|
# function recv_file(file)
|
||||||
# Gets a file from the server and saves it under $TEMP. Paths are not
|
# Gets a file from the server and saves it under $TEMP. Paths are not
|
||||||
|
@ -256,6 +312,29 @@ FEOF1
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# **********************************************************************
|
||||||
|
# function switch(var1, var2)
|
||||||
|
# Switches the values of var1 and var2
|
||||||
|
# **********************************************************************
|
||||||
|
function switch {
|
||||||
|
eval "TEMP=\"\$$1\""
|
||||||
|
eval "$1=\"\$$2\""
|
||||||
|
eval "$2=\"\$TEMP\""
|
||||||
|
}
|
||||||
|
|
||||||
|
# **********************************************************************
|
||||||
|
# function switch_servers()
|
||||||
|
# Switches the target server
|
||||||
|
# **********************************************************************
|
||||||
|
function switch_servers {
|
||||||
|
switch TRANSFER_MODE SECONDARY_TRANSFER_MODE
|
||||||
|
switch SERVER_IP SECONDARY_SERVER_IP
|
||||||
|
switch SERVER_PORT SECONDARY_SERVER_PORT
|
||||||
|
switch TENTACLE_OPTS SECONDARY_TENTACLE_OPTS
|
||||||
|
switch SERVER_PATH SECONDARY_SERVER_PATH
|
||||||
|
switch SERVER_PWD SECONDARY_SERVER_PWD
|
||||||
|
}
|
||||||
|
|
||||||
# **********************************************************************
|
# **********************************************************************
|
||||||
# function check_remote_config()
|
# function check_remote_config()
|
||||||
# Checks for a newer remote configuration file.
|
# Checks for a newer remote configuration file.
|
||||||
|
@ -557,7 +636,7 @@ do
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Send packets to server and delete it
|
# Send packets to server and delete it
|
||||||
send_file $DATA
|
send_file_secure $DATA
|
||||||
|
|
||||||
# Delete data
|
# Delete data
|
||||||
rm -f $DATA > /dev/null 2> $PANDORA_LOGFILE.err
|
rm -f $DATA > /dev/null 2> $PANDORA_LOGFILE.err
|
||||||
|
|
|
@ -59,6 +59,21 @@ transfer_mode tentacle
|
||||||
# If set to 1 allows the agent to be configured via the web console.
|
# If set to 1 allows the agent to be configured via the web console.
|
||||||
# remote_config 0
|
# remote_config 0
|
||||||
|
|
||||||
|
# Secondary server configuration
|
||||||
|
# ==============================
|
||||||
|
|
||||||
|
# If secondary_mode is set to on_error, data files are copied to the secondary
|
||||||
|
# server only if the primary server fails. If set to always, data files are
|
||||||
|
# always copied to the secondary server.
|
||||||
|
# secondary_mode on_error
|
||||||
|
# secondary_server_ip localhost
|
||||||
|
# secondary_server_path /var/spool/pandora/data_in
|
||||||
|
# secondary_server_port 41121
|
||||||
|
# secondary_transfer_mode tentacle
|
||||||
|
# secondary_server_pwd mypassword
|
||||||
|
# secondary_server_ssl no
|
||||||
|
# secondary_server_opts
|
||||||
|
|
||||||
# Module Definition
|
# Module Definition
|
||||||
# =================
|
# =================
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue