Marek Mahut - Patch that fixes the insecure temporary file and minor modifications --- abgraph.sh.upstream 2008-05-20 21:56:51.000000000 +0200 +++ abgraph.sh 2008-05-29 16:40:21.000000000 +0200 @@ -1,10 +1,11 @@ #!/bin/sh ## Copyright 2007 Lennart Koopmann [lennart@dev-my.org] +## Copyright 2008 Marek Mahut ## ## This program is distributed under the terms of the GNU General Public License (GPL) -VERSION="Version 1.0 (01.09.2007) \n" +VERSION="Version 1.1 (29.05.2008)" ## TODO: check if host is up | @@ -40,7 +41,14 @@ then - # move the gnuplot instructions to /tmp/abgraph-plotme + # + ABGRAPH_DATA1=$(mktemp); + ABGRAPH_DATA2=$(mktemp); + ABGRAPH_DATA3=$(mktemp); + ABGRAPH_PLOTME=$(mktemp); + + + # move the gnuplot instructions to $ABGRAPH_PLOTME echo "set terminal png set output '$2' set title 'Benchmark results of $1' @@ -48,48 +56,50 @@ set key left top set xlabel 'request' set ylabel 'ms' - plot '/tmp/abgraph-data1' using 10 with lines title 'Benchmark 1 ($3/1)', '/tmp/abgraph-data2' using 10 with lines title 'Benchmark 2 ($3/25)', '/tmp/abgraph-data3' using 10 with lines title 'Benchmark 3 ($3/50)' - " > /tmp/abgraph-plotme + plot '$ABGRAPH_DATA1' using 10 with lines title 'Benchmark 1 ($3/1)', '$ABGRAPH_DATA2' using 10 with lines title 'Benchmark 2 ($3/25)', '$ABGRAPH_DATA3' using 10 with lines title 'Benchmark 3 ($3/50)' + " > $ABGRAPH_PLOTME # first benchmark echo "Benchmarking... 1/3 ($3 HTTP requests)"; - $ABLOC -n $3 -g /tmp/abgraph-data1 $1 > /dev/null - echo "Great.\nContinuing..."; + $ABLOC -n $3 -g $ABGRAPH_DATA1 $1 > /dev/null + echo "Great. Continuing..."; # sleep 5 seconds - echo "\nsleeping 5 seconds...\n" + echo "sleeping 5 seconds..." sleep 5 # second benchmark echo "Benchmarking... 2/3 ($3 HTTP requests, simulating 25 concurrent users)"; - $ABLOC -n $3 -c 25 -g /tmp/abgraph-data2 $1 > /dev/null - echo "Okay.\nContinuing..."; + $ABLOC -n $3 -c 25 -g $ABGRAPH_DATA2 $1 > /dev/null + echo "Okay. Continuing..."; # sleep 5 seconds - echo "\nsleeping 5 seconds...\n" + echo "sleeping 5 seconds..." sleep 5 # third benchmark echo "Benchmarking... 3/3 ($3 HTTP requests, simulating 50 concurrent users)"; - $ABLOC -n $3 -c 50 -g /tmp/abgraph-data3 $1 > /dev/null + $ABLOC -n $3 -c 50 -g $ABGRAPH_DATA3 $1 > /dev/null - echo "Looks good. Finished!\n"; + echo "Looks good. Finished!"; # generate graph (png saved to user selected path by gnuplot) - $PLOTLOC /tmp/abgraph-plotme > /dev/null + $PLOTLOC $ABGRAPH_PLOTME > /dev/null echo "The graph has been saved to $2"; # tidy up - rm /tmp/abgraph-data1 - rm /tmp/abgraph-data2 - rm /tmp/abgraph-data3 - rm /tmp/abgraph-plotme + rm $ABGRAPH_DATA1 + rm $ABGRAPH_DATA2 + rm $ABGRAPH_DATA3 + rm $ABGRAPH_PLOTME else # display error message on wrong usage + echo echo "Usage: abgraph [hostname to benchmark with http:// and trailing /] [output file .png] [number of requests]" echo "e.g: ./abgraph http://example.com/ /home/myhome/graph.png 500" + echo fi