I'm generating a number of graphs successfully with the awesome RRDTool application. However, I'm having some problems with the VRULE option while graphing.
I'm generating the graphs with a Bash script. For now I'm trying to draw a vertical red line at midnight (at UTC+02:00).
The code to get the last 2 midnight times in epoch:
NOW=`date +%s` DAY=86400 ZONE=7200 LDAY=$((NOW/DAY)) MID=$((LDAY*DAY)) SAST=$((MID-ZONE)) YEST=$((SAST-DAY)) So if I echo either $SAST or $YEST, it'll give me the epoch time at midnight last night or the day before.
Here's the working snippet for (one of) the graphs:
$RRDTOOL graph /var/www/images/graphs/wdata36h.png \ --title 'Pi Traffic Count (wlan0)' \ --watermark "Graph Drawn `date`" \ --vertical-label 'Bytes' \ --lower-limit '0' \ --rigid \ --alt-autoscale \ --units=si \ --width '700' \ --height '200' \ --full-size-mode \ --start end-36h \ 'DEF:wrx=/usr/local/bin/system/data.rrd:wrx:AVERAGE' \ 'DEF:wtx=/usr/local/bin/system/data.rrd:wtx:AVERAGE' \ 'AREA:wtx#0000FFFF:Upload\:' \ 'GPRINT:wtx:LAST:\:%8.2lf %s]' \ 'STACK:wrx#00CC00FF:Download\:' \ 'GPRINT:wrx:LAST:\:%8.2lf %s]' As you can see, the graph spans the last 36 hours which includes 2 midnights. I've tried adding the $SAST and $YEST variables a few ways, but it keeps reading them as the variable names, not as the variable values.
I've tried adding:
'VRULE:$YEST#FF0000' \ 'VRULE:$SAST#FF0000' \ and
'VDEF:yest=$YEST' \ 'VDEF:sast=$SAST' \ 'VRULE:yest#FF0000' \ 'VRULE:sast#FF0000' \ But the quote marks are causing the variables to be interpreted as variable names.
I really do not want to recreate the data.rrd file as it has lots of historic data in it. This means that I'd need to draw those vertical lines in the graph stage and not the update stage.