[rrd-users] Re: Graphing Specific hours from rrd

mrugan mrugan at softhome.net
Wed Feb 11 22:25:04 MET 2004


Hello Yoni,

Ybs> Hello everyone ,
Ybs>   i have some rrd's i want to sum up and graph, however i want to see in the
Ybs>   graph  only hours between 8AM and 6PM.
Ybs>   is that possible using the RPN ?
Ybs>   if so, i imagine the solution is making POP's for the unwanted values,
Ybs>   but have no idea how can that be done.
Ybs>   appriciate on a lead / example .
Ybs>   cheers,
Ybs>   Yoni

Van den Bossche Eric <E.VDB at sherwineu.com> ::: [rrd-users] Re: Color working hours
wrote&shared the expression. i reversed engineered the algo in order
to understand what's happening there....thanks to Alex :)

fast input:

CDEF:workhours=Your_DEF_value_here,POP,TIME,3600,/,2,+,DUP,24,/,7,%,DUP,4,LT,EXC,2,GT,+,2,LT,EXC,24,%,DUP,8,GT,EXC,16,LE,+,2,EQ,1,0,IF,0,IF
CDEF:offhours=Your_DEF_value_here,POP,TIME,3600,/,2,+,DUP,24,/,7,%,DUP,4,LT,EXC,2,GT,+,2,LT,EXC,24,%,DUP,8,GT,EXC,16,LE,+,2,LT,1,0,IF,0,IF
CDEF:weekends=Your_DEF_value_here,POP,TIME,3600,/,2,+,24,/,7,%,DUP,4,LT,EXC,2,GT,+,2,EQ
CDEF:area_weekends=weekends,INF,UNKN,IF
CDEF:area_workhours=workhours,INF,UNKN,IF
CDEF:area_offhours=offhours,INF,UNKN,IF
STACK:area_workhours#fff200:Working Hours 08\\:16\\l
STACK:area_offhours#3d168b:Off Hours\\l
STACK:area_weekends#00a0c1:Weekends\\l

will draw one INFinite AREA if we are in the "timezone" that is 8:00 -
16:00 in the current date Mon-Fri.

Prerequisites:
RPN calculator: http://webplaza.pt.lu/dostert/calc.htm ::: Command line based scientific RPN calculator v3.63

Epoch Time base knowledge: 1 Jan 1970 00:00:00 occured on Thursday (as
a weekday) GMT. (UTC?) ... thus that would be day 0; consecquently Fri
wil be day 1 and so on up until 6th day - Wed;

Getting it done:
Getting the current timesample ... calculating which day in a
week is (see the Thursday thingie) ... at what hour we are (00:00:00
Epoch time equals 00:00:00 our time so there will be no diff.)

Ahead with RPN calculator: EXC function is found as SWAP;
LT,LE,EQ,GE,GT u'll figure it out by >,= operators;
% (modulus) is found as mod;
TIME is rrdtool specific so u'll have to work with a fixed value .. i
suggest converting using one avail. tool the 00:00:00 time each day (Mon, Tue, Wed, etc...)
piece of paper to write the expression result for each day ... in
order to understand what's going on ...

how it works;

_ONE_OF_YOUR_DEFs_HERE_,POP  - will pop out that value ... don't need
that since we are going to perform calculations on TIME
TIME,3600,/ = how many hours since Epoch.
+2 = my localtime (Epoch is always GMT (UTC) ??)
DUP - duplicate the value - the stack now contains {Position0}=(TIME/3600)+2,{Position1}=(TIME/3600)+2
24,/ - take the last value - find out how many days since Epoch
7,% - find out modulus 7 of the prev. value (how many days since epoch
) in order to find out in WHAT day we are situated (remember 0 is
thursday , 1 - friday and so on )
ex: we have a value of 10 days since epoch. %7 will fit one time ...
remaider is 3 - so we are in day 3 of the week - Sunday
DUP - will duplicate the last value - why? so we could perform
calculation on the working day - that is Monday - Friday; Monday is
day 4; Friday is day 1;

Mon Tue Wed Thu Fri Sat Sun
 4   5   6   0   1   2   3

 so if the value is LT 4 / GT 2 the LT/GT functions push onto the
 stack values of 1 or 0; draw on a piece of paper every scenario
 as i said so u will find out for urself why in the end SUM of these
 values of 1 or 0 will result in a number that marks a
 working/non-working day;
 i guess u found out why EXC is needed after we DUP the values.
 (calculate both situations e.g LT 4 / GT 2)

and so on ... we go ... since we have in the stack stored a value of
the hours since Epoch we can calculate modulus of 24 that is in what
our of the day we are situated. similar to the description above ...GT
8, LT 16 values of 1,0 are added onto the stack; second piece of
papaer needed here.

finally the IF function u will have to draw for urself since rpn
calculator doesn't have this one... (rrdtool specific)

the final result of the expression will be either 0 or 1;
so take this result and draw one area: if (0,1) than INF else UNK

your scenario: grahing ONLY 8-16: if (1,0) than YOUR_VALUE_2_PLOT else UNK

have phun;
thanks to alex for explaining DUP,EXC,% & rpn calculator JS engine
 





--
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://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-users mailing list