Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to calculate the bandwidth of my current internet connection. I am pulling the current input and output transfer rate via snmp. If the argument to the following function is a sorted ascending list of the the some of each input and output sample, is this the right way to calculate 95th percentile?

sub ninetyFifth {
    #Expects Sorted Data
    my $ninetyFifthLine = (@_ * .95) - 1;
    return $_[$ninetyFifthLine];
share|improve this question
The perl funkyness is that @_ is the number of items in the list, and that if the index of the array is float it just truncates (rounds down), and as I write this I think I just realized I don't need the - 1 ... – Kyle Brandt Mar 16 '10 at 11:57
Oh and as I read ( this may not be right because I am taking a sample every 10 seconds, so maybe I should convert those samples into 5 minutes averages and then sum those averages, and then takes the 95th? – Kyle Brandt Mar 16 '10 at 12:00
up vote 2 down vote accepted

Usually, the value grabbed via SNMP is "total octets sent/received since last interface counter clear", so unless you've post-processed it to get the "data sent during interval", you'll just end up with "data sent during the first 95% of samples". Though you say "transfer rate", so that should be OK (although if it is the same as is displayed on the show interface information on a Cisco router, it's not actual throughput, it's the exponential average of short-period throughputs).

Otherwise, that looks right. You'll probably end up with a different (and lower) answer when using 5-minute intervals than when using 10-second intervals, unless you have uncharacteristically smooth bandwidth usage, but both would be the 95th percentile for the interval in question.

share|improve this answer
It is a cisco snmp nagios script I grabbed from the exchange, and the data goes up down so it must be through interval. – Kyle Brandt Mar 16 '10 at 14:51
And my 5 minute average was lower as I expected. – Kyle Brandt Mar 16 '10 at 14:52
OK, you want to capture IfOutOctets and IfInOctets and then diff that against the previous entry captured. That way, you can (relatively easily) get measurements for any multiple of your polling interval by ignoring any values between the start and end of the period you want an average transfer rate over. – Vatine Mar 17 '10 at 16:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.