[rrd-users] How to calculate desired value?
spock
collector at sappers.de
Mon Aug 25 21:21:28 CEST 2014
Hi Alex,
ok, I did some more tests with artificial data. See script.
testdata.sh
<http://rrd-mailinglists.937164.n2.nabble.com/file/n7582385/testdata.sh>
Sorry for the confusion between heat_flag and pump_flag, both values
follow the same concept (value 0 = off; value 1 = on; no other values
allowed)
and I want to calculate the total hours.
I am not sure, if I should be more confused than before.
First of all, thanks for the correct formula. If I use the
CDEF:heattime2=heat_flag,24,*
VDEF:totalheattime=heattime2,AVERAGE
I get the desired value - most of the time.
Then I played around with some scenarios:
My timeframe is:
-s 1408917600 -e 1409004000
Mon Aug 25 00:00:00 CEST 2014
Tue Aug 26 00:00:00 CEST 2014
I found out, that the very first value (1408917600)
will NOT be taken into account for the calculation.
This is probably by design.
The very last value is taken into account (1409004000),
this is also by design.
My mistake was, that I did not always use a complete 24h timeframe for the
graph creation.
The other mistake was, that the calculation does not work, if you have
missing values within
the timeframe.
For that reason, I substituted missing values with "0" using:
CDEF:heattimeclean=heat_flag,UN,0,heat_flag,IF \
and then used the cleaned time series for the calculation.
CDEF:heattime2=heattimeclean,24,* \
VDEF:totalheattimeclean=heattime2,AVERAGE \
Question (1):
Unfortunately this introduces (rounding?) errors.
In my artificial testdata I have 17 x "1" values for heat_flag; which
corresponds to 4.25h of heattime.
The totalheattime is calculated as "4.25" - perfect!
But the totalheattimeclean is calculated as 4.21 - is this a rounding error?
I do not understand this, because the heat_flag,UN,0,heat_flag,IF should not
touch the original values, only unknowns.
How do I avoid the rounding?
Question (2)
My other problem is:
On my original "production" database, I have always the above described
"rounding" error - but for both values!
If I re-create the very same day in my artificial database, I get the
rounding errors only for the cleaned values.
We have 8.25h of heating time
"Production" database:
For this day (Aug. 21) with 8.25h heattime I get:
totalheattimeclean = totalheattime = 8.16h
"Artificial" database:
For this day (Aug. 21) with 8.25h heattime I get:
totalheattimeclean = 8.16; totalheattime = 8.25h
I thought, well, I am comparing apples with oranges.
I verified:
- parameters are the identical (copy & paste any and all parameter into
testdata script)
- used same environment (e.g. export LANG=de_DE.UTF8)
- used the same data
I took the data from my "production" rrd database and wrote it with enclosed
script into a new rrd database.
I then did a fetch with
rrdtool fetch /testtemp/temp_pool_debug.rrd -s 1408572000 -e 1408658400
AVERAGE
on both databases and compared the resulting file - no difference except for
the timestamp
1408659300, which is outside of the timeframe. Or is this the key?
The resulting graphs from production and artificial database look completly
identical - except for the calculated heattime.
Do you have an explanation for that?
-->
Regards,
Spock
--
View this message in context: http://rrd-mailinglists.937164.n2.nabble.com/How-to-calculate-desired-value-tp7582375p7582385.html
Sent from the RRDtool Users Mailinglist mailing list archive at Nabble.com.
More information about the rrd-users
mailing list