1#!/bin/sh 2# 3# Driver script to run resperf and generate an HTML report of 4# the results, with graphs. 5# 6 7# Program locations - change these if not in $PATH 8resperf=resperf 9gnuplot=gnuplot 10 11# The gnuplot terminal type. This determines the image format for the 12# plots; "png" or "gif" will both work as long as the corresponding 13# terminal support is compiled into your copy of gnuplot. 14terminal=png 15 16# Create a unique ID for this report 17id=`date '+%Y%m%d-%H%M'` 18 19# Set up file names 20reportfile="$id.html" 21outputfile="$id.output" 22plotfile="$id.gnuplot" 23rate_graph="$id.rate.$terminal" 24latency_graph="$id.latency.$terminal" 25 26# Run the test 27$resperf -P "$plotfile" "$@" >"$outputfile" 2>&1 || 28 { echo "`basename $0`: error running resperf:" >&2; 29 cat $outputfile >&2; 30 exit 1; 31 } 32 33# Create plots 34 35if 36 $gnuplot <<EOF 37set terminal $terminal 38set output "$rate_graph" 39set title "Query / response / failure rate" 40set key top left 41set xlabel "Time (seconds)" 42set yrange [0:] 43plot \ 44"$plotfile" using 1:3 title "Queries sent per second" with lines, \ 45"$plotfile" using 1:4 title "Total responses received per second" with lines, \ 46"$plotfile" using 1:5 title "Failure responses received per second" with lines 47EOF 48then 49 : 50else 51 echo "`basename $0`: error running gnuplot" >&2; exit 1; 52fi 53 54if 55 $gnuplot <<EOF 56set terminal $terminal 57set output "$latency_graph" 58set title "Latency" 59set key top left 60set xlabel "Time (seconds)" 61set yrange [0:] 62plot \ 63"$plotfile" using 1:6 title "Average latency (seconds)" with lines 64EOF 65then 66 : 67else 68 echo "`basename $0`: error running gnuplot" >&2; exit 1; 69fi 70 71# Generate the report 72 73exec >"$reportfile" 74 75cat <<EOF 76<html><head></head><body> 77<h1>Resperf report $id</h1> 78<h2>Resperf output</h2> 79<pre> 80EOF 81cat "$outputfile" 82cat <<EOF 83</pre> 84EOF 85 86cat <<EOF 87<h2>Plots</h2> 88<p> 89<img src="$rate_graph" /> 90<img src="$latency_graph" /> 91</p> 92</body></html> 93EOF 94 95echo "Done, report is in $reportfile" >&2 96 97