[rrd-users] CDEF effects entire timeline

Jacques du Toit jacquesd at irisns.com
Tue Feb 14 20:48:38 CET 2017


If I understand you correctly….I think you’re having issues trying to use NOW because rrdtool will snap to the 1 second grid skewing your calculations ever so slightly. I don’t think it’s really designed for that. It would probably expect DEF like ( TMPOUT, TMPIN, AMOUNT_OF_WATER) and then just graph the values with something like:


And then let rrdtool calculate the value per second (which is what you have with your 1 second step).

But I can see that unless you measure at precisely 1 second intervals down to the millisecond your values will be slightly erratic as the amount of water will vary for each 1-second RRA.

Something I would try to do is to compensate for this using python to store the millisecond value since the last measurement (period = time_now - last_measured_time). Then do something like:


But it’s a bit counter rrdtool to save the “step” in an rrd in this way. You might actually just be better off doing all the maths in python and just writing the PWR as a GAUGE value in rrdtool…that’s probably what I’d do, but I’m lazy with RPN that way… :)


> On 14 Feb 2017, at 20:31, SolarMan <hans at vega.demon.nl> wrote:
> I have a simple application to determine the power generated by a water
> heater. One sensor (TEMPIN) measures the in-flowing cold water temperature
> while a second sensor (TEMPOUT) does the same for the hot water exiting the
> heater. The flow rate is constant and samples are stored in an rrd database.
> Using rrdgraph I want to display the time series of the temperatures plus
> the generated power in Watt. I planned to use a CDEF to calculate the power
> by multiplying the temperature difference by the flowrate and a constant and
> divide that by the time between two successive samples. A python script does
> it all for me. Samples come in nominally - but not exactly - at a one-second
> interval, therefore the CDEF does the division using a value calculated in
> python using rrdtool.last() just before every rrdtool.update() call and NOW
> in the CDEF as you might guess. Seems not all too complex you would say....
> BUT: I noticed that the entire Power graph (PWR) jumps up and down over the
> entire time range when the time-interval (hence the division) changes and
> that is clearly not what I want.
> Here is the CDEF (as a python snippet):           
> "CDEF:PWR=TMPOUT,TMPIN,-," + str(flowrate) + ",*,0.06978,*,NOW," +
> str(prevtime) + ",-,/",
> I spent many hours reading all the available material on CDEF, VDEF etc. but
> this fenomenon apparently has never come up - or this is a feature "by
> design".
> How can I accomplish that the power is calculated and displayed truly
> momentary per step even when the measuring interval varies?
> Thanks everyone!
> --
> View this message in context: http://rrd-mailinglists.937164.n2.nabble.com/CDEF-effects-entire-timeline-tp7583504.html
> Sent from the RRDtool Users Mailinglist mailing list archive at Nabble.com.
> _______________________________________________
> rrd-users mailing list
> rrd-users at lists.oetiker.ch
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.oetiker.ch/pipermail/rrd-users/attachments/20170214/47c74c2c/attachment.html>

More information about the rrd-users mailing list