我已经实现了两个域的基准测试并将它们绘制在单个图中。现在剩下的就是更改各个域的绘制线的颜色。
plot=$plot" 'benchmark_server_data_$counter.dat' using 10 smooth sbezier with lines title '$x' lc rgb 'blue'" # This is the line where i need to replace blue with array
例如,对于 domain1.org 我想要绿色,对于 domain2.com 我想要蓝色。我想我需要创建一个颜色数组并使用 for 循环。我已经尝试过,但遇到了很多麻烦。
while [ $i -lt 1 ]
do
what="http://domain1.org/,http://domain2.com/"
if [ -z "${what}" ];
then
echo "You did not specify a webserver to benchmark!"
else
OIFS=$IFS
IFS=','
arr=$what
counter=0
echo "set term png transparent truecolor" >> _temp.txt
#echo "set terminal png" >> _temp.txt
echo "set output 'out.png'" >> _temp.txt
echo "set title 'CodersHangout Webserver' tc rgb 'green' font 'Times-Roman, 20'" >> _temp.txt
echo "set size 1,1" >> _temp.txt
echo "set key left top tc rgb 'black' " >> _temp.txt
echo "set grid y " >> _temp.txt
echo "set xlabel 'Requests' font 'Times-Roman, 25' tc rgb 'green'" >> _temp.txt
echo "set ylabel 'Response time (ms)' font 'Times-Roman, 25' tc rgb 'green'" >> _temp.txt
echo "set xtics font 'Times-Roman, 20' tc rgb 'green'" >> _temp.txt
echo "set ytics font 'Times-Roman, 20' tc rgb 'green'" >> _temp.txt
echo "set object 1 rectangle from graph 0, graph 0 to graph 1, graph 1 behind fc rgbcolor 'gray' fs noborder" >> _temp.txt
plot="plot"
for x in $arr
do
echo "> Running benchmark for $x"
if [ "$counter" -gt 0 ];
then
plot=$plot","
fi
plot=$plot" 'benchmark_server_data_$counter.dat' using 10 smooth sbezier with lines title '$x' lc rgb 'blue'" #Need to change the color of curve for different domains!
ab -n $total -c $concurrent -k -g benchmark_server_data_$counter.dat -H 'Accept-Encoding:gzip,deflate' $x
counter=$(( counter + 1 ))
done
IFS=$OIFS
echo $plot >> _temp.txt
gnuplot _temp.txt
rm _temp.txt
rm benchmark_server_data_*
exec /opt/lampp/htdocs/serverstat/autoftp.sh
exit
fi
i=1
done