diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index aea45f6288..8ea0e34c65 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2011-09-12 Sancho Lerena + + * util/pandora_remote_agent.sh: New remote agent script to do customized + deployments creating XML files from external scriptfiles. See docs. + 2011-09-12 Vanessa Gil * pandora_server/util/pandora_manage.pl: Applied Kosaka's patch to store diff --git a/pandora_server/util/pandora_remote_agent.sh b/pandora_server/util/pandora_remote_agent.sh new file mode 100755 index 0000000000..f76aa1a4bd --- /dev/null +++ b/pandora_server/util/pandora_remote_agent.sh @@ -0,0 +1,88 @@ +#!/bin/bash +# (c) 2011 Sancho Lerena +# This is a remote agent script, to use local plugins from a distant server. +# You can run this from a local pandora agent. +# Run with -h to see more information + +# Configurable tokens +TEMP=/tmp +OUTPUTDIR=/var/spool/pandora/data_in +OS_NAME=Linux +ENCODING="iso-8859-1" +INTERVAL=300 + +function help { + echo -e "" + echo -e "Remote agent script for Pandora FMS. http://pandorafms.com" + echo -e "Syntax:" + echo -e "\t-a agent Agent name as will be presented in the output XML" + echo -e "\t-f scriptfile Script file to execute. It must generate the XML for modules itself" + echo -e "\t-h This help" + echo "" + exit +} + +if [ $# -eq 0 ] +then + help +fi + +AGENT="" +SCRIPTFILE="" + +while getopts ":h:a:f:" optname + do + case "$optname" in + "h") + help + ;; + "a") + AGENT=$OPTARG + ;; + "f") + SCRIPTFILE=$OPTARG + ;; + ?) + help + ;; + default) + help + ;; + + esac +done + +if [ -z "$AGENT" ] +then + help + exit +fi + +if [ -z "$SCRIPTFILE" ] +then + help + exit +fi + + +# Date and time, SERIAL is number of seconds since 1/1/1970, for every packet. +TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"` +SERIAL=`date +"%s"` + +# File names +DATA=$TEMP/$AGENT.$SERIAL.data + +# Makes data packet +echo " " > $DATA +echo "" >> $DATA + +# Execute the script file +eval $SCRIPTFILE >> $DATA + +# Finish data packet +echo "" >> $DATA +echo "" >> $DATA + +# Moving to target directory +mv $DATA $OUTPUTDIR +