[rrd-users] Confusion about VDEF total and graph values
Alex van den Bogaerdt
alex at vandenbogaerdt.nl
Fri Oct 14 13:05:22 CEST 2016
> It would be nice if I could draw vertical lines after each interval from
> height=rate/value to the x-axis. That way the graph would look more like a
> histogram which might help making the correct interpretation more easy. I
> looked at VRULE, but that's not going to help here as far as I can tell.
You mean you want to see the same bars, only reduced in width? In other
words, get smaller bars with gaps inbetween?
If not, stop reading and explain further.
Okay, you're still here. Do get the desired effect, you do want to graph
the portion of the bar at the beginning of each hour, and not the
remainder. Or maybe half a bar, centered around half of the hour.
One bar per hour, so you need to repeat every hour: time_in_seconds modulo
You end up with a number 0 <= timeval < 3600.
Then you decide to graph the bar if 'timeval' is inbetween some arbitrary
limits. If it is not, then you graph nothing.
For instance: graph if timeval <1800. Or graph if 900 <= timeval <= 1800.
First a heads up: the following procedure may not work. If so, we need to
implement a trick. It depends on the internal resolution rrdgraph is
working with. I will explain after I'm done building the CDEF.
I know what I want but I still look in the manual:
I see LIMIT, TIME, and % which means modulo. While building the CDEF I
notice I need to compare against unknown and I need to push unknown on the
stack: IF, UN and UNKN.
if ((time modulo 3600) inbetween 900,1800) return value else return unknown
time modulo 3600: TIME,3600,%
inbetween 900,1800: 900,1800,LIMIT
You now have some value 900..1800, or unknown.
Test against unknown: UN
You now have true or false, for outside limits, inside limits.
It will also be true when the input value was unknown (meaning: no data
if (true) then return unknown else return value.
we already have true (or false) on the stack. We need to push unknown and
the original value:
And then push command 'IF' to select one of these two.
This leads to the following CDEF:
Instead of orig, you could also work with orig x 3600. Just insert
"3600,*," before IF
I showed you how I think it can be done, but I did not test anything.
There will be other ways to reach the same or a similar outcome. You can
alter the limits to alter the resulting bars.
You need to test this CDEF and correct any mistakes I made.
So, what was the problem which may occur? If rrdtool graph is working
internally with slots of 3600 seconds, then TIME,3600,% will always return
0. This means you can not work with portions of an hour.
The solution is then to include another datasource, one that has a better
resolution, to force rrdtool graph to work with smaller intervals. You
don't really have to display that other data source, you would only
(ab)use it to tweak the inner workings of RRDtool.
There may be other, less resource intensive, ways to accomplish this goal.
And you may not have to do it at all. You figure this out yourself.
I suggest you read the tutorial and especially the part where we generate
alternating background colors. It works in a similar way.
> The gas meter itself updates in real-time, however the smart meter (from
> which I get the data) only 'asks' the gas meter once every hour for the
> counter value at that time. This can't be influenced, so as far as I can
> tell a step size smaller than 3600 doesn't make sense in this case.
Sounds logical to me as well.
If you'd have step sizes smaller than 3600 seconds and measure more often
than every 3600 seconds, you would end up will all gas used during the
last of each step, and zero in the others. Definately not want you want.
> the smart meter also gives me power data and does so every 10 seconds, I
> actually read (and store) the gas counter value and power values also at a
> 10 second interval. Therefor I decided to use the LAST CF for the gas
> counter. The MAX CF would probably have the same effect since the counter
> is only going up.
No, this is incorrect. You really should study how RRDtool works because
right now you will be in for nasty surprises later on.
Remember what I said: you are working with surfaces, not with width or
Suppose later, when everything seems to be working, you will want to
display a graph showing usage for a month? You cannot show 31 x 24 bars,
so you will use >>>consolidated<<< data. You will, for instance, combine
24 hours into one 'day' (in UTC time, so 22:00-22:00 during summer,
23:00-23:00 during winter).
You end up with 31 bars where each bar describes a rate during 86400 seconds.
Write down 24 consecutive rates. They will differ during the day.
How do you want to combine these 24 rates into 1 ?
Hint: you do not want the last of these 24 (but you are doing that now:
Hint: you do not want the highest of these 24 (but that would happen when
using MAX CF).
Once more: surface, not rate.
More information about the rrd-users