[rrd-users] Daily consumption

Alex van den Bogaerdt alex at vandenbogaerdt.nl
Mon Nov 14 09:01:04 CET 2016

> Hi all !
> I leave in France, and having a RPi and a very basic UART adapter, I can
> retrieve some data from my electricity Meter. I could create some basic
> RRDTool graphs, and I can now foolow my instantaneous consumption.
> Here is my db creation :
> rrdtool create edf \
>                --start now \
>                --step 60 \
>                DS:cpt:COUNTER:60:0:U \
>                RRA:AVERAGE:0.5:1:12 \
>                RRA:AVERAGE:0.5:12:48 \
>                RRA:AVERAGE:0.5:288:365 \
> The "cpt" value is the electricity counter raw value (in Wh), meaning
> electric consumption since the beginning (a very big number, which can
> only
> increase). I update it every 10s.

It is not wrong, but I wonder if it is what you meant to do:
You have "--step 60" and update every 10 seconds. Your finest RRA will
still contain a composed number built from 6 updates.
Again: it is not wrong. However, combined with your actual question this
makes me wonder if you do fully understand what is happening and what you
are collecting.

It means your RRAs collect 12 minutes, 9.6 hours and 73 days. Rates older
than 73 days will not be available in your database.

That last RRA, ":288:365" contains slots of 288 minutes (4 hours 48
minutes) and has 365 of such slots. The numbers appear to be copied from
some example which collects "daily" data (288 times 5 minutes is exactly
one day, have 365 of those makes one year). Again an indicator that you
should study RRDtool a bit more.

> What I want now is to have my daily consumption. I want a graph which
> clearly show what was my total consumption yesterday, and the day before,
> and the day before etc.

If you mean: one vertical line / bar per day, then you need to be aware
that RRDtool works in UTC time. Your "days" are off by one hour during
winter, and by two hours during summer.

If you show units of 24 hours, and if you multiply the resulting average
rates by 86400 (use a CDEF for this), you will see consumption per 24
hours. Those units however will start and end at midnight UTC, so right
now in French local time they will start and end at time 01:00.

You will also need to make sure the graph area fits the shown data, e.g.
to display 30 days in a row, make sure to display on a graph which is n*30
pixels wide + set start and end to n*86400 seconds.
1: find the latest midnight UTC, by taking the timestamp right now and
round down to the nearest multiple of 86400
2: use this as end time      ( --end {$var_containing_endtime} )
3: set start to be end-2592000   (which is 86400 times 30) ( --start
end-2592000 )
4: set graph width to be 450  (or another number n times 30) ( --width 450 )

For many this will be good enough.

I believe this is as close as RRDtool will get. If you need another job to
be done, you will need to use another tool.


More information about the rrd-users mailing list