# HG changeset patch # User ketan # Date 1381868521 14400 # Node ID 7aa6ee21028cda5b0ee666e344424f805e383293 # Parent a015252417edf19ee91fa026e9eb46c0756b89a2 Uploaded diff -r a015252417ed -r 7aa6ee21028c swift-hello --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/swift-hello Tue Oct 15 16:22:01 2013 -0400 @@ -0,0 +1,224 @@ +#!/bin/bash + +site=$1 +n=$2 +outdir=$3 +logfile=$4 +htmlfile=$5 +mkdir -p $outdir +echo $@ >> /tmp/args.txt + +swift=`\which swift` + +# use "here" document for configs +cat << EOF > /tmp/hello.swift +type file; + +app (file o) helloapp (string msg) { + echo msg stdout=@o; +} + +file out[]; + +foreach j in [1:@toInt(@arg("n","2"))] { + out[j] = helloapp ("Hello World!"); +} +EOF + +case "$site" in +cluster ) +cat << 'EOF' > /tmp/sites.xml + + + + + default + 8 + 02:00:00 + 7500 + 100 + 100 + 1 + 1 + 1 + .31 + 10000 + /tmp/swift.workdir + + +EOF + +cat << 'EOF' > /tmp/tc +cluster echo echo +cluster cat cat +EOF + +cat << 'EOF' > /tmp/cf +use.provider.staging=true +wrapperlog.always.transfer=true +execution.retries=1 +provider.staging.pin.swiftfiles=false +sitedir.keep=true +lazy.errors=false +EOF +;; + +localhost ) +cat << 'EOF' > /tmp/sites.xml + + + + + 0.01 + 10000 + + /tmp/swift.work + local + + +EOF + +cat << 'EOF' > /tmp/tc +localhost echo echo +localhost cat cat +EOF + +cat << 'EOF' > /tmp/cf +use.provider.staging=false +wrapperlog.always.transfer=true +execution.retries=0 +provider.staging.pin.swiftfiles=false +sitedir.keep=true +lazy.errors=false +EOF +;; + +* ) +echo "defaulting to localhost" + +cat << 'EOF' > /tmp/sites.xml + + + + + 0.01 + 10000 + + /tmp/swift.work + local + + +EOF + +cat << 'EOF' > /tmp/tc +localhost echo echo +localhost cat cat +EOF + +cat << 'EOF' > /tmp/cf +use.provider.staging=false +wrapperlog.always.transfer=true +execution.retries=0 +provider.staging.pin.swiftfiles=false +sitedir.keep=true +lazy.errors=false +EOF +;; +esac + +$swift -sites.file /tmp/sites.xml -tc.file /tmp/tc -config /tmp/cf /tmp/hello.swift -n=$n -data=$data 2> std.err +EXITCODE=$? + +swiftlog=`\ls -t *.log | head -1` + +cat << 'EOF' > /tmp/plotswiftlogs +#!/bin/bash + +#usage: ./extract4plots + +SWIFTLOGFILE=$1 +#TMPDIR=`mktemp -d plotlog.XXX` +grep -i ProgressTicker $SWIFTLOGFILE > swiftoutfile.out +SWIFTOUTFILE=swiftoutfile.out +#extract start time +TMPDATE=`grep -i progress $SWIFTOUTFILE 2>/dev/null | head -n 1 | cut -f1-2 -d ' '` +START_TIME=`date +%s -d "$TMPDATE"` + +#extract end time +TMPDATE=`grep -i progress $SWIFTOUTFILE 2>/dev/null | tail -n 1 | cut -f1-2 -d ' '` +END_TIME=`date +%s -d "$TMPDATE"` + +#duration +DIFFTIME=$((END_TIME - START_TIME)) +#echo 0 > active.txt +#echo 0 > cumulative.txt +#extract active runs in a file +(grep -o -i "Active:[0-9]*" $SWIFTOUTFILE 2>/dev/null | awk -F: '{print $2}' > active.txt) + +#extract successful completions in a file +(grep -o -i "Successfully:[0-9]*" $SWIFTOUTFILE 2>/dev/null | awk -F: '{print $2}' > cumulative.txt) + +#prepare tics +activelines=`wc -l active.txt | awk '{print $1}'` +cumulines=`wc -l cumulative.txt | awk '{print $1}'` + +if [ $activelines -ne 0 ] +then + activelinespertic=`echo "scale=5 ; $DIFFTIME / $activelines" | bc` +fi +seq 0 $activelinespertic $DIFFTIME > activetics.txt + +if [ $cumulines -ne 0 ] +then + cumulinespertic=`echo "scale=5 ; $DIFFTIME / $cumulines" | bc` +fi + +seq 0 $cumulinespertic $DIFFTIME > cumultics.txt + +#final plot data +paste activetics.txt active.txt > plot_active.txt +paste cumultics.txt cumulative.txt > plot_cumulative.txt + +cat << EOF1 > plotit.gp +set terminal png enhanced +set output "activeplot.png" +set nokey +set xlabel "Time in sec" +set ylabel "number of active jobs" +set title "Active jobs" +plot "plot_active.txt" using 1:2 with line + +set output "cumulativeplot.png" +set ylabel "number of completed jobs" +set title "Cumulative jobs" +plot "plot_cumulative.txt" using 1:2 with lines +EOF1 + +gnuplot plotit.gp 2>/dev/null + +#cp *.png ../ +echo `pwd`>/tmp/curdir +echo `ls`>/tmp/dirlist +#cd .. +EOF + +cat << EOF > $htmlfile + + + + + Hello output + + +

Browse output of hello application

+`for i in \`find $outdir -type f\`; do echo "Output: \`basename $i\`
"; done` + + +EOF + +if [ "$EXITCODE" -ne "0" ]; then + cat std.err >&2 +fi +cp std.err $logfile +rm std.err +exit $EXITCODE