# [rrd-users] question for an "average counter" rrd

Alex van den Bogaerdt alex at vandenbogaerdt.nl
Sat Feb 23 15:51:52 CET 2013

```----- Original Message -----
From: "Matthias Lemke" <m at box.li>
To: <rrd-users at lists.oetiker.ch>
Sent: Saturday, February 23, 2013 3:32 PM
Subject: Re: [rrd-users] question for an "average counter" rrd

>
>
> On 23.02.2013 15:14, Alex van den Bogaerdt wrote:
>>> I habe a pellet oven with webinterface (austrian ETA). The webinterface
>>> works perfect. I can read and set most of the values.
>>>
>>> Two of the values are counter:
>>> - pelles in kg
>>> - working time in seconds
>>>
>>> I put the pellets in kg in a counter rrd. So I can see for instance
>>> pellets/day vs. outside temperature.
>>
>> Internally RRDtool will compute and store the number of kilograms per
>> second.
>>
>
> Yes right, I multiply with 86400 ...

That means your RRD has a rate of kilogram per day, showing that even if you
query only a couple of hours.
Not a problem if that's not going to happen anyway.
The example number I showed, should be divided by 86400 in this case.

>> If you print the average of those 365 values in your graph, you have the
>> average number of kilograms per day measured over an entire year.
>
> puh, how can I do this?

Using GPRINT, see the docs.  Or use PRINT if you want the number as text
output.

>> A year is 365 times 24 times 60 times 60 seconds. That is 31536000
>> seconds.

>> Just multiply the rate you already have in your RRD by 31536000, and then

so just multiply (see the docs on CDEF) by 365.

>> compute the average. The outcome will be the number of kilograms during
>> the
>> past 365 days, which is the sliding window you want.
>
> Here I need also a hint or help how I can do this...

It's a similar GPRINT command, but first you use CDEF to muliply by 365 and
then you GPRINT the outcome of the multiplication.

DEF:kgperday=....
CDEF:kgperyear=kgperday,365,*
GPRINT:kgperyear:AVERAGE:%6.2lf

should get you started

```