Search code examples
rrdtool

Unexpected (wrong?) values


I want to store the value of two solar inverters in a rrd. I get the values over modbus as absolute values (increasing counters). I created my rrd like this:

rrdtool create -s 60 /data/solar.rrd --no-overwrite \
  DS:WR1:COUNTER:300:0:U \
  DS:WR2:COUNTER:300:0:U \
  RRA:AVERAGE:0.5:1:43200 \
  RRA:AVERAGE:0.5:5:25920 \
  RRA:AVERAGE:0.5:60:8784 \
  RRA:AVERAGE:0.5:1440:18993 \
  RRA:MAX:0.5:1440:18993

Using a bit of Python, I insert values into this rrd with (with debug output):

rrdtool.update("/data/solar.rrd","-t","WR1:WR2","N:%i:%i" % (d1.inverter.WH,d2.inverter.WH))

info = rrdtool.info("/data/solar.rrd")
print "%i %i %i" % (info['last_update'],d1.inverter.WH,d2.inverter.WH)

Running it in a loop:

user@machine:~# while(true); do sleep 60; ./get_data4rrd.py; done
1504028308 3521906 1870096
1504028369 3521911 1870097
1504028430 3521916 1870097
1504028491 3521921 1870098
1504028552 3521925 1870098

So I would expect that for DS WR1 I'll get something between 4 and 6 for this values. But when doing a fetch it's wildly different:

user@machine:/data# rrdtool fetch solar.rrd AVERAGE -r 1m -s -15m
                            WR1                 WR2

1504028400: 8.1857862607e-02 8.0323781910e-03
1504028460: 8.1857458806e-02 8.0440194250e-03
1504028520: 7.4102207109e-02 8.6226472416e-03
1504028580: 6.5478084175e-02 0.0000000000e+00

I know that rrdtool aligns my input to fit the step width, but I would still expect the output for DS WR1 to be something around 4-6 and not 0.08.

What's wrong here? I can't figure my error out.


Solution

  • The man page clearly states that the values are always stored as rate/s. If you expect it to be rate/stepwidth you need to multiply your value:

    CDEF:expection=DS,stepwidth,*
    

    or even better in the case you want kWh

    CDEF:WR1kWh=WR1,3.6,*