[rrd-users] Re: blocky graph with description (update/solutions)

Sebastian Pachuta seba123 at seba123.webd.pl
Wed Oct 18 10:15:38 MEST 2006


On Tue, Oct 17, 2006 at 08:58:57 +0200, Sebastian Pachuta wrote:
> 
> Hi Tobias, rrd-users

Ok, here is update about this issue.
Yes, it might be considered as an bug or feature.
It does not matter at this point.

> Here are my RRA-s from create:
>   RRA:AVERAGE:0.5:1:1400 \
>   RRA:AVERAGE:0.5:3:1400 \
>   RRA:AVERAGE:0.5:13:1400 \
>   RRA:AVERAGE:0.5:151:1400
> step is 300

Q: Am I affected?
A: Look at Your steps in RRAs definition.
In my example they are: 1,3,13,151
Now do the math:

  3 %  1 = 0 - good
 13 %  3 = 1 - bad
151 % 13 = 8 - bad

% - modulo

non affected examples: 1,3,6,24; 1,2,8,16; 1,4,12,36
affected ones: 1,2,7,14; 1,3,15,31; 1,4,21,42

> Problem is that sometimes second graph is blocky. Please look at this 
> time line (one char is step - 5min):
> 
> first rra 111111111111111111111111111111111111111111111111111111111111111111111
> 2-nd one  <3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3>
> third     <     13    ><     13    ><     13    ><     13    ><     13    ><
>                      ->XX<-       ->X<-        -><-         ->XX<-       ->X<-

Q: How to trigger this issue?
A: Draw time chart for Your steps from RRAs. Mark 'X' places like I do.
Then set '--end' for 'now' in graph code and wait until You step on 'X' mark.

> X char indicates time areas when rrd tool chooses third RRA for drawing
> second one graph. Maybe after third rra updates its values, rrdtool thinks
> that this data is more suitable (recent?) for drawing graph.

Q: Why it happens?
A: rrdtool tries to choose best RRA from RRD file.
According to 'src/rrd_fetch.c' file, best RRA is that one which covers whole 
requested time frame. It's called 'best full match'.
Look again at my 'time graph'. At 'X' places. There is one row (CDP) missing 
from RRA(3) - most recent one.
In that case RRA(13) is better, because it contains all required information,
even at lower resolution.

> Solutions?

Q: How can I fix it?
A: Create RRAs which are not affected.

> 1/ I don't care
> fix rra selection in rrdtool

A1: We cam modify RRA selector to ignore missing row (most recent one).
In that case we get chance to choose RRA with better resolution.

Here is patch:

src/rrd_fetch.c     2006-10-18 10:04:12.000000000 +0200
@@ -237,7 +237,7 @@
            tmp_step_diff = labs(*step - (rrd.stat_head->pdp_step
                                           * rrd.rra_def[i].pdp_cnt));
            /* best full match */
-           if(cal_end >= *end
+           if(cal_end + (rrd.stat_head->pdp_step * rrd.rra_def[i].pdp_cnt) >= *end
               && cal_start <= *start){
                if (first_full || (tmp_step_diff < best_full_step_diff)){
                    first_full=0;

> 3/ Lame
> Do not use 'now' for '--end'.
> 
> $now = date +%s				; get now
> $now = $now - ( $now % (300*3) )	; round it to 15min backwards
> $start = $now - ... some value we use alone with '-' sign ...

A2: Setting '--end' for last row (in preferred RRA) is good solution.
Before doing it check (using dump) some timestamps from every RRA:

RRA(1):
1161088200 % (1*300) = 0
1161088500 % (1*300) = 0
1161088800 % (1*300) = 0
RRA(3):
1161086400 % (3*300) = 0
1161087300 % (3*300) = 0
1161088200 % (3*300) = 0
RRA(13):
1161080700 % (13*300) = 0
1161084600 % (13*300) = 0
1161088500 % (13*300) = 0
RRA(151):
1160993700 % (151*300) = 0
1161039000 % (151*300) = 0
1161084300 % (151*300) = 0

Lucky for us rrdtool uses clever timestamps.

Here is example of php code which generates good '--end' values:

$now = gettimeofday();
$now = $now['sec'];
if (!isset($_GET['type'])) {
   $_GET['type']='';
}
switch ($_GET['type']) {
case 'day':
   $now = $now - ($now % 300 );
   $cfg = array_merge(array('--end',$now,'--start',$now-210000,'-w','700','-h','144'), $cfg);
   break;
case 'week':
   $now = $now - ($now % 900 );
   $cfg = array_merge(array('--end',$now,'--start',$now-630000,'-w','700','-h','144'), $cfg);
   break;
case 'month':
   $now = $now - ($now % 3900 );
   $cfg = array_merge(array('--end',$now,'--start',$now-2730000,'-w','700','-h','144'), $cfg);
   break;
case 'year':
   $now = $now - ($now % 45300 );
   $cfg = array_merge(array('--end',$now,'--start',$now-31710000,'-w','700','-h','144'), $cfg);
   break;
default:
   $now = $now - ($now % 300 );
   $cfg = array_merge(array('--end',$now,'--start',$now-125700,'-w','419','-h','144'), $cfg);
}


Regards

-- 
Sebastian Pachuta
seba123 at seba123.webd.pl

--
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