monitoring the real user experience

Just start Xvfb on a different Port: /usr/bin/Xvfb :2 Then tell Firefox where the DISPLAY is: firefox –display=127.0.0.1:2.0 But first we have to pimp Firefox a little bit. … Put all this together and you have a browser which can be startet on a headless system (with Xvfb), given an url to render, renders the page, saves the rendered page as an image and closes.

…-ne 0 ]; then /usr/bin/nohup /usr/bin/Xvfb :3 & > /dev/null 2>&1 fi } function make_graph () { /home/ff-render/make_graphs.sh > /dev/null 2>&1 } function move_screenshot () { mv /home/ff-render/Desktop/ff-screenshot.png /home/ff-render/public_html/ } function update_rrd () { /usr/bin/rrdupdate ${RRDFILE} N:${1} } function notify () { if [ `(echo “${RENDERTIME} > ${MAXTIME}”|bc)` -eq 1 ]; then echo “Max-Rendertime: ${MAXTIME} Actual Time: ${1}” | /usr/bin/mutt -c $NOTIFYMAIL -s “Spiegel Rendertime exceeded: $1” -a /home/ff-render/public_html/ff-screenshot.png ${NOTIFYMAIL} fi } function kill_old_instance () { for PID in `ps -ef | grep -v grep | grep firefox | grep saveimage | awk ‘{print $2}’`; do kill -9 $PID done } check_xvfb kill_old_instance RENDERTIME=`/usr/bin/time -f “time-elapsed:%e” /usr/bin/firefox –display=127.0.0.1:3.0 -saveimage $URL -width 1000 -height 700 2>&1 | /usr/bin/awk -F: ‘/time-elapsed/ {print $2}’` # RENDERTIME=`/usr/bin/time -f “time-elapsed:%e” /usr/bin/firefox -saveimage $URL -width 1000 -height 700 2>&1 | /usr/bin/awk -F: ‘/time-elapsed/ {print $2}’` update_rrd ${RENDERTIME} make_graph move_screenshot notify ${RENDERTIME} This script creates the appropriate RRD file

…#scriptname: create_screenshot_rrd.sh rrdtool create firefox-forum-render-store.rrd –start `perl -e ‘print time,’` –step 60 \ DS:Render-Time:GAUGE:70:U:50 \ RRA:AVERAGE:0.5:1:240 \ RRA:AVERAGE:0.5:5:2016 \ RRA:AVERAGE:0.5:10:288 \ RRA:AVERAGE:0.5:30:17520 \ RRA:MAX:0.5:1:240 \ RRA:MAX:0.5:5:2016 \ RRA:MAX:0.5:10:288 \ RRA:MAX:0.5:30:17520 \ RRA:MIN:0.5:1:240 \ RRA:MIN:0.5:5:144 \ RRA:MIN:0.5:10:288 \ RRA:MIN:0.5:30:17520 This script creates the graphs

…/bin/bash CURRTIME=`date` function create_graph () { /usr/bin/rrdtool graph /home/ff-render/public_html/${store}1h.png -E –start -3600 \ -v “Sekunden” \ -t “Renderzeit $PAGENAME” \ -W “Datum: $CURRTIME” \ -w 800 -h 300 \ DEF:TEMP=/home/ff-render/$store.rrd:Render-Time:AVERAGE:step=60 \ LINE1:TEMP#0000FF:”Zeit” \ HRULE:7.0#000000:”Limit 7.0 Sec” \ COMMENT:”1 Stunde” /usr/bin/rrdtool graph /home/ff-render/public_html/${store}12h.png -E –start -43200 \ -v “Sekunden” \ -t “Renderzeit $PAGENAME” \ -W “Datum: $CURRTIME” \ -w 800 -h 300 \ DEF:TEMP=/home/ff-render/$store.rrd:Render-Time:AVERAGE:step=60 \ DEF:MAX=/home/ff-render/$store.rrd:Render-Time:MAX:step=60 \ DEF:MIN=/home/ff-render/$store.rrd:Render-Time:MIN:step=60 \ LINE1:TEMP#0000FF:”Durchschnitt” \ LINE1:MAX#FF0000:”Max” \ LINE1:MIN#00FF00:”Min” \ HRULE:7.0#000000:”Limit 7.0 Sec” \ COMMENT:”12 Stunden” /usr/bin/rrdtool graph /home/ff-render/public_html/${store}24h.png -E –start -86400 \ -v “Sekunden” \ -t “Renderzeit $PAGENAME” \ -W “Datum: $CURRTIME” \ -w 800 -h 300 \ DEF:TEMP=/home/ff-render/$store.rrd:Render-Time:AVERAGE:step=60 \ DEF:MAX=/home/ff-render/$store.rrd:Render-Time:MAX:step=60 \ DEF:MIN=/home/ff-render/$store.rrd:Render-Time:MIN:step=60 \ LINE1:TEMP#0000FF:”Durchschnitt” \ LINE1:MAX#FF0000:”Max” \ LINE1:MIN#00FF00:”Min” \ HRULE:7.0#000000:”Limit 7.0 Sec” \ COMMENT:”24 Stunden” /usr/bin/rrdtool graph /home/ff-render/public_html/${store}7d.png -E –start -604800 \ -v “Sekunden” \ -t “Renderzeit $PAGENAME” \ -W “Datum: $CURRTIME” \ -w 800 -h 300 \ DEF:TEMP=/home/ff-render/$store.rrd:Render-Time:AVERAGE:step=60 \ DEF:MAX=/home/ff-render/$store.rrd:Render-Time:MAX:step=60 \ DEF:MIN=/home/ff-render/$store.rrd:Render-Time:MIN:step=60 \ LINE1:TEMP#0000FF:”Durchschnitt” \ LINE1:MAX#FF0000:”Max” \ LINE1:MIN#00FF00:”Min” \ HRULE:7.0#000000:”Limit 7.0 Sec” \ COMMENT:”7 Tage” /usr/bin/rrdtool graph /home/ff-render/public_html/${store}1m.png -E –start -2592000 \ -v “Sekunden” \ -t “Renderzeit $PAGENAME” \ -W “Datum: $CURRTIME” \ -w 800 -h 300 \ DEF:TEMP=/home/ff-render/$store.rrd:Render-Time:AVERAGE:step=60 \ DEF:MAX=/home/ff-render/$store.rrd:Render-Time:MAX:step=60 \ DEF:MIN=/home/ff-render/$store.rrd:Render-Time:MIN:step=60 \ LINE1:TEMP#0000FF:”Durchschnitt” \ LINE1:MAX#FF0000:”Max” \ LINE1:MIN#00FF00:”Min” \ HRULE:7.0#000000:”Limit 7.0 Sec” \ COMMENT:”30 Tage” /usr/bin/rrdtool graph /home/ff-render/public_html/${store}6m.png -E –start -14860800 \ -v “Sekunden” \ -t “Renderzeit $PAGENAME” \ -W “Datum: $CURRTIME” \ -w 800 -h 300 \ DEF:TEMP=/home/ff-render/$store.rrd:Render-Time:AVERAGE:step=60 \ DEF:MAX=/home/ff-render/$store.rrd:Render-Time:MAX:step=60 \ DEF:MIN=/home/ff-render/$store.rrd:Render-Time:MIN:step=60 \ LINE1:TEMP#0000FF:”Durchschnitt” \ LINE1:MAX#FF0000:”Max” \ LINE1:MIN#00FF00:”Min” \ HRULE:7.0#000000:”Limit 7.0 Sec” \ COMMENT:”6 Monate” } STORES=”firefox-forum-render-store” for store in $STORES; do create_graph $store; done exit 0

Continue reading…