Last active
September 4, 2015 15:32
-
-
Save voltuer/4c04dfcefa5748702b6f to your computer and use it in GitHub Desktop.
Crear grafico con Apache Benchmark (ab)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Ejecuta un Apache Benchmark (ab) y lo grafica usando gnuplot | |
#tamaño imagen | |
w=1200 | |
h=600 | |
#úsame :3 pero úsame bien | |
uso="Uso: $0 <host> [<concurrentes> <totales>] [archivo sin punto]\nEjemplo: $0 http://54.148.131.11/ust-home/ 1 2 imagen\n\n" | |
[[ $1 == "" ]] && printf "$uso" && exit | |
[[ $1 != "" ]] && host=$1 | |
[[ $2 != "" ]] && [[ $3 == "" ]] && printf "$uso" && exit | |
[[ $4 != "" ]] && [[ "${4: -4:1}" == "." ]] && printf "$uso (SIN PUNTO!)" && exit | |
#variables qls de archivos | |
tmp=$(date | md5) && tmp=${tmp:0:7} | |
data=$tmp.data | |
png=$tmp.png | |
ab=/tmp/ab-$tmp | |
plot=/tmp/plot-$tmp | |
[[ $4 != "" ]] && png=$4.png | |
#template pa gnuplot | |
PLOT=" | |
set terminal png size $w,$h | |
set size 1, 1 | |
set output \"$png\" | |
set title \"$3 solicitudes ($2 conexiones concurrentes) \n $host\" | |
set key left top | |
set grid y | |
set xdata time | |
set timefmt \"%s\" | |
set format x \"%S\" | |
set xlabel 'segundos' | |
set ylabel \"tiempo respuesta (ms)\" | |
set datafile separator '\t' | |
plot \"$ab\" every ::2 using 2:5 title '' with points | |
" | |
echo "$PLOT" > $plot | |
echo "* AB ($ab)" && ab -c $2 -n $3 -g $ab $host | |
echo "* PLOT ($plot)" && gnuplot $plot || exit 0 | |
[[ $4 != "" ]] && open $png | |
[[ $4 == "" ]] && echo "* Terminado!! Imagen quedó en $png" | |
# subl plot.xd | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment