2008-05-29 Sancho Lerena <slerena@gmail.com>

* openWRT/README.openwrt: Some additional information about wput command  
        replacing old SSH transfer method.

        * openWRT/pandora_agent: Updated to use ftp(wput) instead of buggy ssh.

        * openWRT/pandora_agent.conf: Deleted ssh method and unused stuff for
        this little agent.

        * linux/plugins/grep_log: Updated plugin to use a module name for each
        call, passed as 2th argument.

        * linux/pandora_agent.conf: Deleted checksum reference and commented
        plugin sample, and using the new syntax for plugin.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@841 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2008-05-29 14:33:54 +00:00
parent e4124a61b4
commit 7267b41682
6 changed files with 69 additions and 74 deletions

View File

@ -1,3 +1,19 @@
2008-05-29 Sancho Lerena <slerena@gmail.com>
* openWRT/README.openwrt: Some additional information about wput command
replacing old SSH transfer method.
* openWRT/pandora_agent: Updated to use ftp(wput) instead of buggy ssh.
* openWRT/pandora_agent.conf: Deleted ssh method and unused stuff for
this little agent.
* linux/plugins/grep_log: Updated plugin to use a module name for each
call, passed as 2th argument.
* linux/pandora_agent.conf: Deleted checksum reference and commented
plugin sample, and using the new syntax for plugin.
2008-05-27 Ramon Novoa <rnovoa@artica.es>
* linux/pandora_agent.conf: Added a plugin declaration example.

View File

@ -18,7 +18,7 @@ interval 300
# Debug mode only generate XML, and stop after first execution,
# and does not copy XML to server.
debug 0
debug 1
# By default, agent takes machine name
#agent_name adama
@ -28,7 +28,7 @@ debug 0
# Listening TCP port for remote server. By default is 41121 (for tentacle)
# if you want to use SSH use 22, and FTP uses 21.
server_port 21
server_port 41121
# Transfer mode: tentacle, ftp, ssh or local
transfer_mode tentacle
@ -72,6 +72,12 @@ module_min 0
module_descripcion User CPU Usage (%)
module_end
module_begin
module_name Remote_Cisco_Port14_status
module_type generic_proc
module_exec snmpget -v 1 -c artica06 192.168.50.250 IF-MIB::ifOperStatus.13
module_end
module_begin
module_name cpu_sys
module_type generic_data
@ -127,4 +133,8 @@ module_exec ps -Af | grep sshd | grep -v "grep" | wc -l
module_end
# Plugin example
#module_plugin grep_log /var/log/pandora/pandora_agent.log.err err
# This parses /var/log/syslog file, under the module name "syslog"
# And search for "ssh" string into it, sending only that information.
module_plugin grep_log /var/log/syslog Syslog ssh

View File

@ -27,11 +27,14 @@ use File::Basename;
my $Verbose = 0;
# Index file storage directory, with a trailing '/'
my $Idx_dir='/var/pandora/';
my $Idx_dir='/tmp/';
# Log file
my $Log_file = '';
# Module name
my $Module_name = "default_log";
# Index file
my $Idx_file = '';
@ -63,7 +66,7 @@ sub error_msg ($) {
# Print a help message.
###############################################################################
sub print_help () {
print "Usage: $0 <log_file> <pattern>\n";
print "Usage: $0 <log_file> <module_name> <pattern>\n";
}
###############################################################################
@ -169,7 +172,7 @@ sub parse_log () {
seek(LOGFILE, $Idx_pos, 0);
print (stdout "<module>\n");
print (stdout "<name><![CDATA[" . basename($0) . "]]></name>\n");
print (stdout "<name><![CDATA[" . $Module_name . "]]></name>\n");
print (stdout "<type><![CDATA[generic_data_string]]></type>\n");
print (stdout "<datalist>\n");
@ -208,7 +211,8 @@ if ($#ARGV != 1) {
}
$Log_file = $ARGV[0];
$Reg_exp = $ARGV[1];
$Module_name = $ARGV[1];
$Reg_exp = $ARGV[2];
# Create index file storage directory
if ( ! -d $Idx_dir) {

View File

@ -0,0 +1,3 @@
wput replaces scp/ssh to copy using FTP. A future addition of tentacle is expected. You will need to install wput on your OpenWRT system and setup a FTP server in Pandora Server to work (dont forget to secure your ftp server!).

View File

@ -1,13 +1,14 @@
#!/bin/sh
# **********************************************************************
# Pandora FMS Generic Host Agent
# GNU/Linux version
# (c) 2003-2007 Sancho Lerena <slerena@gmail.com>
# Pandora FMS Agent
# OpenWRT version
# (c) 2003-2008 Sancho Lerena <slerena@gmail.com>
# (c) 2007-2008 Jorge Loza <jorge@netberry.es>
# with the help of many people. Please see http://pandora.sourceforge.net
# This code is licensed under GPL 2.0 license.
# **********************************************************************
AGENT_VERSION=1.3-dev
AGENT_BUILD=070421
AGENT_VERSION=2.0
AGENT_BUILD=080529
if [ -z "$1" ]
then
@ -16,7 +17,7 @@ then
echo " "
echo " example: pandora_agent /etc/pandora "
echo " "
exit -1
exit
else
PANDORA_HOME=$1
fi
@ -26,7 +27,7 @@ then
echo " "
echo "FATAL ERROR: Cannot load $PANDORA_HOME/pandora_agent.conf"
echo " "
exit -1
exit
fi
# Init internal variables
@ -40,9 +41,10 @@ IFS="
# Default values
CHECKSUM_MODE=1
DEBUG_MODE=0
SERVER_PORT=22
SERVER_PORT=21
INTERVAL=300
TRANSFER_MODE=ssh
TRANSFER_MODE=ftp
SERVER_PWD=pandora123
if [ -z "`echo $LANG | grep '\.'`" ]
then
ENCODING="iso-8859-1"
@ -94,47 +96,33 @@ do
DEBUG_MODE=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - Debug mode is $DEBUG_MODE " >> $PANDORA_LOGFILE
fi
if [ ! -z "`echo $a | grep -e '^checksum'`" ]
then
CHECKSUM_MODE=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - Checksum is $CHECKSUM_MODE " >> $PANDORA_LOGFILE
fi
# Contribution of daggett
if [ ! -z "`echo $a | grep -e '^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 -e '^encoding'`" ]
then
ENCODING=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - Encoding is $ENCODING" >> $PANDORA_LOGFILE
fi
if [ ! -z "`echo $a | grep -e '^transfer_mode'`" ]
if [ ! -z "`echo $a | grep -e '^server_pwd'`" ]
then
TRANSFER_MODE=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - Transfer Mode is $TRANSFER_MODE" >> $PANDORA_LOGFILE
SERVER_PWD=`echo $a | awk '{ print $2 }' `
echo "$TIMESTAMP - [SETUP] - Server password set (FTP)" >> $PANDORA_LOGFILE
fi
done
# Script banner at start
echo "Pandora FMS Agent / Linksys $AGENT_VERSION (c) Sancho Lerena, Jorge Loza 2007"
echo "Pandora FMS Agent / Linksys $AGENT_VERSION (c) Sancho Lerena, Jorge Loza 2008"
echo "This program is licensed under GPL2 Terms. http://pandora.sf.net"
echo "Running in $NOMBRE_HOST at $TIMESTAMP"
echo " "
# 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"
@ -154,8 +142,6 @@ do
# File names
DATA=$TEMP/$NOMBRE_HOST.$SERIAL.data
DATA2=$TEMP/$NOMBRE_HOST.$SERIAL.data_temp
CHECKSUM=$TEMP/$NOMBRE_HOST.$SERIAL.checksum
PANDORA_FILES="$TEMP/$NOMBRE_HOST.$SERIAL.*"
# Makes data packet
echo "<?xml version=\"1.0\" encoding=\"$ENCODING\"?> " > $DATA
@ -264,17 +250,6 @@ do
/bin/sh $PANDORA_HOME/pandora_user.conf >> $DATA
fi
# Checking MD5
if [ "$CHECKSUM_MODE" = "1" ]
then
# Calculate Checksum and prepare MD5 file
CHECKSUM_DATA=`md5sum $DATA`
echo $CHECKSUM_DATA > $CHECKSUM
else
CHECKSUM_DATA="No valid checksum"
echo $CHECKSUM_DATA > $CHECKSUM
fi
# Finish data packet
echo "</agent_data>" >> $DATA
echo "" >> $DATA
@ -292,24 +267,10 @@ do
exit 0
fi
# Send packets to server and detele it
if [ "$TRANSFER_MODE" = "ssh" ]
then
scp -i /opt/pandora/ssh $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
cd $TEMP
wput -q $NOMBRE_HOST.$SERIAL.data ftp://pandora:$SERVER_PWD@$SERVER_IP:$SERVER_PORT
# Delete data
rm -f $PANDORA_FILES 2> $PANDORA_LOGFILE.err
rm -f $DATA 2> $PANDORA_LOGFILE.err
# Go to bed :-)
sleep $INTERVAL

View File

@ -18,20 +18,21 @@ interval 30
# and does not copy XML to server.
debug 0
# By default is activated
checksum 0
# By default, agent takes machine name
agent_name arduinoasus
# By default agent try to take default encoding defined in host.
# encoding iso-8859-15
# By default is 22 (for ssh)
#server_port 22
# By default is 21 for ftp
server_port 21
# ftp, ssh or local
transfer_mode ssh
# only ftp at this time.
transfer_mode ftp
# server pass
server_pwd pandora
# Module Definition
# =================