[rrd-users] RRD PERCENT question (95 percentile)

Joe Loiacono jloiacon at csc.com
Wed May 12 15:32:24 CEST 2010


See this link for a close look into the problem:

https://lists.oetiker.ch/pipermail/rrd-users/2008-January/013582.html

Joe Loiacono




From:
"Alex van den Bogaerdt" <alex at vandenbogaerdt.nl>
To:
<rrd-users at lists.oetiker.ch>
Date:
05/12/2010 03:09 AM
Subject:
Re: [rrd-users] RRD PERCENT question (95 percentile)



> Hello List,
>
> I'm a happy RRD user, but there's something I need help with.
> We're currently moving to RRDtool for accounting & billing.
> For this I've created RRD files that keep 105120 5minute samples (1 
year).
>
> Now I'm comparing the 95% numbers generated by RRDtool with the 95%
> number generated by our old script. The problem is that these numbers
> are significantly different.

Note that "the" 95th percentile does not exist. There are many different 
methods of computing this value, and although they are similar and will 
more 
or less provide the same result, they do differ.

I don't recall exactly how I started, but I think originally I used 
data[n*steps/100]. Then, after some discussion on the mailing list, 
round() 
was introduced.

> I hope someone can help me understand why these numbers are so 
different.

Because if the array index changes by only one, the returned value may be 
quite different.

> This is how I determine the 95 percentile number using RRDtool
>
[snipped some]
>         VDEF:95thin=inbits,95,PERCENT \
>         VDEF:95thout=outbits,95,PERCENT \

Looking fine.

> My manual test was done like this:
> 1) fetch rawdata:
> /usr/local/rrdtool-1.2.19/bin/rrdtool fetch \
> --start '1271894400' --end '1272240000' \
> "deviceid11_XXX_Transit.rrd" AVERAGE  > OUT_RAW;
>
> 2) read this data with a perl script than sort values and show 95% 
number.
>
> In this case the data set contains 1153 samples (no NaN in sample).
> so after sorting the 95% percentile should be the value (times 8 for
> bits) on position 1096.

> The problem is that this number is quite different (lower) from what is
> returned using PERCENT above.

Please see if the number on position 1095 or 1097 equals that of what 
rrdtool finds.

> Note that this sample does not contain any NaN values.
> I also tried this with the latest version of RRDtool, same result.
>
> Can anyone explain why this is different? Is this expected?
> How exactly does RRD this internally?

Create an array, fill it with the data, use qsort  and then find the 
correct 
spot:

qsort(array, step, sizeof(double), vdef_percent_compar);
field = round((dst->vf.param * (double)(steps - 1)) / 100.0);
dst->vf.val = array[field];

In here, vdef_percent_compar is a function that sorts NAN < -INF < numbers 
< 
+INF

Your calculation: 1153 samples, 95% = 1095,35 so you take 1096.
RRDtool: round(95*1152/100)=1094, based on an array with first member is 
0, 
so 1094 is the 1095th position.
If I recall correctly, the original version did use truncation instead of 
rounding, which makes no difference in this case.

Anyway, unless I made a mistake here, rrdtool takes data[1094] and you 
take 
data[1096].  Your returned value should be higher than what RRDtool 
reports.

> I would like to use RRDtool for this, but need to be sure that the
> numbers are correct, i.e understand why the numbers are different than
> when calculated manually.

I would also worry why it is opposite to what I reasoned above.

_______________________________________________
rrd-users mailing list
rrd-users at lists.oetiker.ch
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/rrd-users/attachments/20100512/a33e2af4/attachment.htm 


More information about the rrd-users mailing list