```
local_rate_graph() {
rrdtool graph \
"$1" \
--start end-$4 \
--width 823 \
--height 217 \
--step "$5" \
--title "$3 message rate" \
--vertical-label "messages/second" \
--lower-limit 0 \
--units-exponent 0 \
--right-axis 360:0 \
--slope-mode \
"DEF:messages=$2/dump1090_messages-local_accepted.rrd:value:AVERAGE" \
#Get the average value for each of the preceeding 7 days.
"DEF:a=$2/dump1090_messages-local_accepted.rrd:value:AVERAGE:end=now-86400:start=end-86400" \
"DEF:b=$2/dump1090_messages-local_accepted.rrd:value:AVERAGE:end=now-172800:start=end-86400" \
"DEF:c=$2/dump1090_messages-local_accepted.rrd:value:AVERAGE:end=now-259200:start=end-86400" \
"DEF:d=$2/dump1090_messages-local_accepted.rrd:value:AVERAGE:end=now-345600:start=end-86400" \
"DEF:e=$2/dump1090_messages-local_accepted.rrd:value:AVERAGE:end=now-432000:start=end-86400" \
"DEF:f=$2/dump1090_messages-local_accepted.rrd:value:AVERAGE:end=now-518400:start=end-86400" \
"DEF:g=$2/dump1090_messages-local_accepted.rrd:value:AVERAGE:end=now-604800:start=end-86400" \
#Gets the minimum values for the preceeding 7 days.
"DEF:amin=$2/dump1090_messages-local_accepted.rrd:value:MIN:end=now-86400:start=end-86400" \
"DEF:bmin=$2/dump1090_messages-local_accepted.rrd:value:MIN:end=now-172800:start=end-86400" \
"DEF:cmin=$2/dump1090_messages-local_accepted.rrd:value:MIN:end=now-259200:start=end-86400" \
"DEF:dmin=$2/dump1090_messages-local_accepted.rrd:value:MIN:end=now-345600:start=end-86400" \
"DEF:emin=$2/dump1090_messages-local_accepted.rrd:value:MIN:end=now-432000:start=end-86400" \
"DEF:fmin=$2/dump1090_messages-local_accepted.rrd:value:MIN:end=now-518400:start=end-86400" \
"DEF:gmin=$2/dump1090_messages-local_accepted.rrd:value:MIN:end=now-604800:start=end-86400" \
#Get the maximum value for the preceeding 7 days
"DEF:amax=$2/dump1090_messages-local_accepted.rrd:value:MAX:end=now-86400:start=end-86400" \
"DEF:bmax=$2/dump1090_messages-local_accepted.rrd:value:MAX:end=now-172800:start=end-86400" \
"DEF:cmax=$2/dump1090_messages-local_accepted.rrd:value:MAX:end=now-259200:start=end-86400" \
"DEF:dmax=$2/dump1090_messages-local_accepted.rrd:value:MAX:end=now-345600:start=end-86400" \
"DEF:emax=$2/dump1090_messages-local_accepted.rrd:value:MAX:end=now-432000:start=end-86400" \
"DEF:fmax=$2/dump1090_messages-local_accepted.rrd:value:MAX:end=now-518400:start=end-86400" \
"DEF:gmax=$2/dump1090_messages-local_accepted.rrd:value:MAX:end=now-604800:start=end-86400" \
"DEF:strong=$2/dump1090_messages-strong_signals.rrd:value:AVERAGE" \
"DEF:positions=$2/dump1090_messages-positions.rrd:value:AVERAGE" \
"CDEF:y2strong=strong,10,*" \
"CDEF:y2positions=positions,10,*" \
#Shift the historical data in time so it can be overlaid with the current data.
"SHIFT:a:86400" \
"SHIFT:b:172800" \
"SHIFT:c:259200" \
"SHIFT:d:345600" \
"SHIFT:e:432000" \
"SHIFT:f:518400" \
"SHIFT:g:604800" \
"SHIFT:amin:86400" \
"SHIFT:bmin:172800" \
"SHIFT:cmin:259200" \
"SHIFT:dmin:345600" \
"SHIFT:emin:432000" \
"SHIFT:fmin:518400" \
"SHIFT:gmin:604800" \
"SHIFT:amax:86400" \
"SHIFT:bmax:172800" \
"SHIFT:cmax:259200" \
"SHIFT:dmax:345600" \
"SHIFT:emax:432000" \
"SHIFT:fmax:518400" \
"SHIFT:gmax:604800" \
#Calculate the 7 day average
"CDEF:7dayaverage=a,b,c,d,e,f,g,+,+,+,+,+,+,7,/" \
#Find the minimum and maximum data from the preceeding 7 days. This could probably be done in two lines, but I'm not a programmer and RPN makes my head hurt.
"CDEF:min1=amin,bmin,MINNAN" \
"CDEF:min2=cmin,dmin,MINNAN" \
"CDEF:min3=emin,fmin,MINNAN" \
"CDEF:min4=min1,min2,MINNAN" \
"CDEF:min5=min3,gmin,MINNAN" \
"CDEF:min=min4,min5,MINNAN" \
"CDEF:max1=amax,bmax,MAXNAN" \
"CDEF:max2=cmax,dmax,MAXNAN" \
"CDEF:max3=emax,fmax,MAXNAN" \
"CDEF:max4=max1,max2,MAXNAN" \
"CDEF:max5=max3,gmax,MAXNAN" \
"CDEF:max=max4,max5,MAXNAN" \
#Calculation in order to get an area between max and min values.
"CDEF:maxarea=max,min,-" \
#Draw graphs.
"LINE1:min#FFFF99:mins" \
"AREA:maxarea#FFFF99:max:STACK" \
"LINE1:7dayaverage#00FF00:7 day average" \
"AREA:y2strong#FF0000:messages >-3dBFS / hr (RHS)" \
"LINE1:y2positions#00c0FF:positions / hr (RHS)" \
"LINE1:messages#0000FF:messages received"
}
```