# [rrd-users] Re: 95th percentile

Stephan Harren sh at abovenet.de
Wed Apr 23 15:59:19 MEST 2003

```#!/usr/bin/perl

my \$line;
my \$value;
my \$percentile95;
my @rrdfetch;
my @allvalues;

@rrdfetch=qx(/usr/local/rrdtool-1.0.39/bin/rrdtool fetch testfile.rrd AVERAGE
-s -30000 -e -300);
chomp @array;
foreach \$line (@rrdfetch) {
split(/\s+/,\$line);
\$value=(\$_[1] > \$_[2]) ? \$_[1] : \$_[2];
push (@allvalues,\$value);
}
@allvalues=sort {\$a <=> \$b} @allvalues;
foreach (@allvalues) {
print "\$_\n";
}
\$percentile95=sprintf("%.2f",(\$allvalues[(sprintf("%.0f",(@allvalues*0.95))-1)]*8/1000));
print "\$percentile95 KBytes\n";

This is an example where I use an rrd with in and outvalue. Which one I
choose, I decide by every line so I take the higher 5-minute-value (IN or
OUT) into final calculation. It is also possible to calculate an
IN-percentile and an OUT-percentile and than take the higher one.

HTH,

Stephan

Am Mittwoch, 23. April 2003 15:15 schrieb Tony:
> All the data is 5 minute values.
> I can use fetch to get the data for the last month from the database,
> but it's all in scientific notation, how do I convert this to whole
> numbers?
>
> I'm currently trying to work on a perl script to work out the 95th
> percentile, but getting it to drop the highest 5% is a pain.
>
> Tony
>

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