[rrd-users] rate per day graph from rate per hour DS

Ben Griffith griffithba at gmail.com
Tue Jan 30 07:07:30 CET 2007


Thanks Alex!  With your help I think I've got it all figured out.

On 1/29/07, Alex van den Bogaerdt <alex at ergens.op.het.net> wrote:
>
> On Mon, Jan 29, 2007 at 05:34:33PM -0500, Ben Griffith wrote:
> > Hi,
> >
> > I have a RRD that was defined as follows:
> >
> > rrdtool create $sensor.rrd -s 3600 \
> >        DS:minutes:ABSOLUTE:3600:0:60 \
> >        RRA:MAX:0.5:1:4800
> >
> > Once per minute the RRD is updated with a 1 if my boiler is running, or
> a 0
> > if it is not.
>
> An update at 19:01 describes time 19:00 to 19:01.
>
> If your boiler was switched off a fraction of a second before you ran
> your rrdtool command, you will update with a wrong status.
>
> This will of course be countered by the opposite: your boiler switched
> on a fraction of a second ago and you note "1" where the real status
> should have been "0".


I thought of that, but I figured in the end the two cases would cancel each
other out.  I could try updating more frequently.  I think I'd have to
adjust the rate multiplier accordingly.  So if I update every 15 seconds I'd
have to multiply by 900 (number of seconds in an hour divided by the number
of 15 second blocks in a minute) instead of 3600 to get the number of
minutes the boiler was on in an hour.

Your step size is 3600 seconds.  Each minute you add another portion
> of the hourly statistics, I think using an averaging computation.
> (not 100% sure, but pretty sure)


Doesn't it just add up all the entries to get a total for the hour, then
from that a rate per second?  Or does it actually compute the rate
throughout the hour, on the fly?


> > I tried supplying start and end times in the DEF, but the boundaries are
> > still always placed at 19:00.  How can I change that?
>
> Find a way to work with 24 hourly values instead of 1 daily value.


This is the method I chose.  Here's what I came up with:

filename=/usr/local/misterhouse/trunk/data/rrd/Burner_Counter.rrd
timenow=`date | sed 's/:/\\\:/g'`
rrdtool graph /home/griffith/public_html/boiler_day.png \
              --end 00\:00 --start end-7d --x-grid
DAY:7:DAY:7:DAY:1:86400:%A \
              --height 200 --width 500 --imgformat PNG \
              --title "Boiler run-time per day" --vertical-label "minutes" \
              DEF:day1=$filename:minutes:MAX:start="midnight yesterday -
6d":end=start+23h \
              DEF:day2=$filename:minutes:MAX:start="midnight yesterday -
5d":end=start+23h \
              DEF:day3=$filename:minutes:MAX:start="midnight yesterday -
4d":end=start+23h \
              DEF:day4=$filename:minutes:MAX:start="midnight yesterday -
3d":end=start+23h \
              DEF:day5=$filename:minutes:MAX:start="midnight yesterday -
2d":end=start+23h \
              DEF:day6=$filename:minutes:MAX:start="midnight yesterday -
1d":end=start+23h \
              DEF:day7=$filename:minutes:MAX:start="midnight
yesterday":end=start+23h \
              VDEF:minday1=day1,TOTAL \
              VDEF:minday2=day2,TOTAL \
              VDEF:minday3=day3,TOTAL \
              VDEF:minday4=day4,TOTAL \
              VDEF:minday5=day5,TOTAL \
              VDEF:minday6=day6,TOTAL \
              VDEF:minday7=day7,TOTAL \
              CDEF:foo1=day1,minday1,+,day1,- \
              CDEF:foo2=day2,minday2,+,day2,- \
              CDEF:foo3=day3,minday3,+,day3,- \
              CDEF:foo4=day4,minday4,+,day4,- \
              CDEF:foo5=day5,minday5,+,day5,- \
              CDEF:foo6=day6,minday6,+,day6,- \
              CDEF:foo7=day7,minday7,+,day7,- \
              AREA:foo1#ff0000 \
              AREA:foo2#0000ff \
              AREA:foo3#ff0000 \
              AREA:foo4#0000ff \
              AREA:foo5#ff0000 \
              AREA:foo6#0000ff \
              AREA:foo7#ff0000 \
              GPRINT:minday1:"           %.0lf"\
              GPRINT:minday2:"     %.0lf"\
              GPRINT:minday3:"     %.0lf"\
              GPRINT:minday4:"     %.0lf"\
              GPRINT:minday5:"     %.0lf"\
              GPRINT:minday6:"     %.0lf"\
              GPRINT:minday7:"     %.0lf\n"\
              COMMENT:"$timenow"


Using the CDEFs to add in and subtract out each point seems kind of silly
but I couldn't figure out a better way to constrain each VDEF to the day it
belonged in.

Thanks again, Alex.

-Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/rrd-users/attachments/20070130/efd0361a/attachment.html 


More information about the rrd-users mailing list