#!/bin/bash
. ~/.cronenv
if [ -z "$4" ]; then
echo "USAGE: toolgrpahs <rrd-file> <target-dir> <time-span> <title>"
exit 1
fi
rrd="$1"
tgt="$2"
span="$3"
title="$4"
width=700
height=320
name=`basename ${rrd%%.rrd}`
runsimg="$tgt/$name-$span-runs.png"
timeimg="$tgt/$name-$span-time.png"
ftimeimg="$tgt/$name-$span-ftime.png"
ferrimg="$tgt/$name-$span-ferrors.png"
rm "$runsimg" "$timeimg" "$ftimeimg" "$ferrimg"
rrdtool graph "$runsimg" -t "Calls - $title" -v "amount" -A -z -l 0 --imginfo '%s'\
--start="now-$span" --width="$width" --height="$height" --end=now \
"DEF:runs=$rrd:runs:AVERAGE" \
"LINE2:runs#0000BB:requests" \
"DEF:errors=$rrd:errors:AVERAGE" \
"LINE2:errors#BB0000:errors" \
rrdtool graph "$timeimg" -t "Time - $title" -v "seconds" -A -z -l 0 --imginfo '%s' \
--start="now-$span" --width="$width" --height="$height" --end=now \
"DEF:time=$rrd:time:AVERAGE" \
"AREA:time#00BB00:seconds" \
rrdtool graph "$ftimeimg" -t "Time per Call - $title" -v "seconds/call" -A -z -l 0 --imginfo '%s' \
--start="now-$span" --width="$width" --height="$height" --end=now \
"DEF:ftime=$rrd:ftime:AVERAGE" \
"LINE2:ftime#00BB00:seconds per call" \
rrdtool graph "$ferrimg" -t "Errors per Call - $title" -v "errors/call" -A -z -l 0 --imginfo '%s' \
--start="now-$span" --width="$width" --height="$height" --end=now \
"DEF:ferrors=$rrd:ferrors:AVERAGE" \
"LINE2:ferrors#BB0000:errors per call" \
chmod a+r "$runsimg" "$timeimg" "$ftimeimg" "$ferrimg"
toolgraphs
text/x-shellscript, 1551 bytes (load raw)

