[rrd-users] Office Hours calculations (was Re: Re: Migrating RRD data to RDBMS)

Ralf Kruedewagen ralf-buero at kruedewagen.de
Wed Feb 8 08:47:01 MET 2006


Hi Alex,

great, your suggestion was abolutely right. It's simple if you know 
how it works with LTIME and Modulo ;-)
I could implement it successfully with one combined CDEF:

CDEF:ds0_officehours=LTIME,604800,%,3600,47,*,3600,47,48,
+,*,LIMIT,UN,LTIME,86400,
%,3600,8,*,1,+,3600,17,*,LIMIT,UN,UNKN,ds0,IF,UNKN,IF

My office hours are 8h - 17h in this example (see digits 8 and 17). 
Instead of setting values outside office hours to 0 I set it to UNKN.

48 is the length in hours of the weekend beginning on Sat 0h.

One correction: The "week" begins on Thursday (1.1.1970), not on 
Friday. This is the reason for the 47 in the CDEF.

Thanks a lot for your effort
Ralf

On Thursday 26 January 2006 16:14, Alex van den Bogaerdt wrote:
> On Thu, Jan 26, 2006 at 03:08:16PM +0100, Ralf Kruedewagen wrote:
> > My RRD database do not consolidated, since I only use one RRA
> > with steps=1. And my STEP is almost always 900. So, it should
> > fit.
> >
> > If you say "to a certain point", how would you do it ?
>
> Ignoring the daylight saving issue:
>
> You want localtime 8:00 to 18:00.  10 hours per 24 hours.
> Keep that interval each day, set the rest to unknown or to zero.
>
> You want monday to friday.  Keep that interval (which has
> undesired time removed already) and set the rest to unknown or
> to zero.
>
> Remaining: office hours.  The average computed may be too low.
> This will be the case if you used zero to mask out the other
> hours.  Compensate by multiplying by 24/10 and by 7/5.
>
> Without generating complete CDEFs, and without testing and
> debugging, I think the following should get you started:
>
> if (localtime more than 08:00 and less or equal to 18:00) {
>     then use ds0
>     else use value zero
> }
>
> ds0_modified1=LTIME,86400,%,28801,64800,LIMIT,UN,0,ds0,IF
>
> if (localtime between saturday and sunday) {
>     then use value zero
>     else use outcome of previous CDEF
> }
>
> ds0_modified2=LTIME,604800,%,21000,28000,LIMIT,UN,ds0_modified1,0,I
>F
>
> You will need to tweak the numbers 21000 and 28000 so that they
> match the beginning of saturday and the end of sunday.
>
> The numbers are no magic.  Modulo 86400 gives the hour in a day,
> modulo 604800 gives the hour in a week.  Weeks do not start on
> monday, they start on friday 00:00 UTC.
>
> There may be some errors in what I wrote here.  I didn't even
> start up rrdtool; it does however show the way you could be
> working towards a result.

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://lists.ee.ethz.ch/rrd-users
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi



More information about the rrd-users mailing list