[mrtg] Re: 95th percentile ???

David Gabler dgabler at americomusa.net
Thu Mar 16 00:55:13 MET 2000


Here is a 95th percentile generator.  It is the only one I was able to find. 
It works great though!!!  All it does is print a #.  It is written for UNIX,
has not been tested under NT (don't ask how to get it working under NT).  And
it works on MRTG databases I don't know 

I personally use another script which calls this script gets the number then
turns it into a pretty graphical number.

Have fun. 

FYI if you don't have a good definition of the 95th percentile that this will
generate -> DEF: 95% of the time in the most recent 30 days, the bits per
second utilization in the 5 minute interval is
below the reported value.


David Gabler

#!/usr/bin/perl
#
# Generate a percentile calculation from the most recent $samples
# in an MRTG log file.  This isn't the most accurate percentile because
# the sample interval changes twice in the data set.  Once we've got
# it, print the number from the larger of the input or output values.

# Copyright 1997,1998: Labyrinth Computer Services, All Rights Reserved

# Uptated to suite needs 1/2/00 by David Gabler dgabler at americomusa.net

require 5.003;

# Percentile to calculate
$PER=95;


# MRTG data file (usually you get this from the CGI environment)
$file           = $ARGV[0];

open(FILE, "$file") || &Fatal("Couldn't open file: $file \n");

$last=<FILE>;           # throw away header line
$samples=1360;          # 30 days worth at 10 minute intervals in first 600
$bits=8;                # convert bytes to bits
@redux=(600,3,12);      # reduction (every N samples multiply by X, Y...)

for ( $i = 1; $_ = <FILE> ; $i++ ) {
        ($in, $out) = (split)[1,2];
        push(@In,$in);
        push(@Out,$out);
        $factor = int($i/$redux[0]);
        if ($factor != 0) {
                foreach (1..$redux[$factor]) {
                        push(@In,$in);
                        push(@Out,$out);
                }
        }
}

close(FILE);

foreach $set ("In", "Out")
{
        @sorted = sort { $a <=> $b } (@$set);

        $idx = int(@$set * $PER / 100);
        $$set = sprintf("%05d", ($sorted[$idx] * $bits)/1000);
}

if ( $In > $Out )
{
 print $In;
} else
{
 print $Out;
}

# END 


At 01:22 PM 3/15/00 -0800, Greg Kennedy wrote:
>Anyone have a script a gather the 95th % info. 


----------
David Gabler                  Project Manager, Network Services
Americom USA       Phone 805.545.5078

----------


--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:mrtg-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/mrtg



More information about the mrtg mailing list