[rrd-users] VRULE for sunset, sunrise

Joseph Mack NA3T jmack at wm7d.net
Sun Aug 26 18:12:42 CEST 2007

On Sun, 26 Aug 2007, Alex van den Bogaerdt wrote:

> On Sun, Aug 26, 2007 at 06:45:52AM -0700, Joseph Mack NA3T wrote:
>> I'm collecting weather data and would like to plot the
>> sunrise and sunset time with a VRULE. It seems that VRULE
>> must be passed a number, rather than whatever is in a
>> DEF/CDEF variable. I can extract sunset/sunrise into shell
>> variables and plot them with VRULE, but I'd like to be able
>> to save the sunrise/sunset times into a rrd database and
>> recall them later.

thanks for the quick reply.

> Do you want to plot those times, or does it HAVE to be using vrule ?

Over a year I'd like to plot them on their own graph. I can 
do that already, and it wasn't the reason for posting.

Since putting midnight on the graph was so easy with VRULE, 
I assumed for the day graph of temp/humidity, a VRULE for 
sunrise/sunset, would be equally easy. However I'd be happy 
with a light background shading to show the day or night 

> I can think of ways to achieve what you apparently want. Those ways
> do not include VRULE.
> First thing to consider: rrdtool works with intervals, not with
> times

I see, I'll have to think about that. I realise there's a 
few things about rrdtool that I don't understand.

> (except vrule, which won't work afaik).


> You'll have to deal with consolidation, and want to distinguish
> between relevant times (sunset, sunrise) and irrelevant times.
> The database resolution needs to be in the same resolution as you
> want your data. If you have 86400 seconds per rra-row, you won't
> be able to have two different times (time ranges really). This
> means: use one minute per row, or even one second.
> Then think about what you want to see. Do you want a spike at
> sunrise and sunset, or do you want to display daylight and night?

either would be fine

> Intervals have a beginning, duration and end. Suppose you want to
> display the period between sunrise and sunset, you do want to include
> the interval which ends at sunset but you do NOT want to include the
> interval which ends at sunrise.

don't care. Sunrise/Sunset are just decorative guideposts 
on the graph.

> If on the other hand you want spikes, you need mostly UNKN or zero
> in your database, with an occasional INF or high value.

hmm. I could get into trouble if I don't grab a sample near 
enough to sunrise/sunset.

> In both cases: I'm not sure what happens when {UN,UN,UN,UN,INF,UN,UN,UN}
> (for example) is consolidated. Try it. If that results in INF then
> you could use UNKN for graph off and INF for graph on (be it a spike
> or a range). Else, use zero and a huge value, then use a CDEF to
> find the difference between zero and non-zero. Change non-zero into
> INF and continue.
> Graphing is a matter of displaying the resulting data. INF results
> in a bar upto the top of the graph, UNKN or zero won't be visible.

I hadn't thought about any of this. It seems I'm not 
thinking about rrdtool the right way.

If VRULE is not going to do it, how about I just shade 
between sunrise and sunset? To do that, I can extract the 
current value of sunrise and sunset and shade between them 
(presumably I can test LTIME when setting the background and 
see if it's less than sunset AND more that sunrise).

However how would I shade for yesterday? Instead of using 
LTIME, do I calculate


and use that in the background calculation?

Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!

More information about the rrd-users mailing list