X-Git-Url: http://git.onelab.eu/?p=myops.git;a=blobdiff_plain;f=web%2Fcollect%2Fclient%2Fupload.sh;fp=web%2Fcollect%2Fclient%2Fupload.sh;h=02b7c5eddc7b2fad0c88f985bf73899d47e1d137;hp=0000000000000000000000000000000000000000;hb=85070b3d456667f238051af1a2f1f2a0c12300ab;hpb=607f0e13927eb18075c375fa9ba5527da4fcbb44 diff --git a/web/collect/client/upload.sh b/web/collect/client/upload.sh new file mode 100644 index 0000000..02b7c5e --- /dev/null +++ b/web/collect/client/upload.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +#if [ -f /tmp/source/configuration ] ; then +# source /tmp/source/configuration +#elif [ -f /etc/planetlab/plc_config ] ; then +# source /etc/planetlab/plc_config +#else +# PLC_MONITOR_HOST=IPADDR +#fi +#if [[ -z "$PLC_MONITOR_HOST" || "$PLC_MONITOR_HOST" = "localhost.localdomain" ]] ; then +# PLC_MONITOR_HOST=monitor.planet-lab.org +#fi +if [ -f /etc/planetlab/plc_config ]; then + source /etc/planetlab/plc_config +else + PLC_SLICE_PREFIX='pl' +fi + +export MYOPS_SERVER=IPADDR + +function upload_log () +{ + file=$1 + path=$2 + base=$( basename $file ) + old=/tmp/${base}.old + new=/tmp/${base}.new + log=/tmp/${base}.log + if [ ! -f $file ] ; then + return + fi + if [ -f $new ] ; then + cp $new $old + else + touch $old + fi + cp $file $new + #comm -1 -3 $old $new > $log + cp $new $log + if [ $( stat -c %s $log ) -ne 0 ] ; then + curl --max-time 60 --silent http://${MYOPS_SERVER}/upload.php --form "log=@$log" + if [ $? -ne 0 ] ; then + # the upload has failed, so remove new file so no data is lost + rm -f /tmp/$( basename $file ).new + fi + fi +} + +function upload_logs () +{ + upload_log $1 multiops +} + +upload_logs /home/${PLC_SLICE_PREFIX}_myops/myops.log +