Ticket #443 (new enhancement)

Opened 5 years ago

Last modified 2 years ago

95th percentile graphs

Reported by: anarcat Assigned to: janl
Priority: high Milestone: Munin 3.0
Component: design Version:
Severity: normal Keywords:
Cc: anarcat@koumbit.org

Description

It would be nice to have a line that would calculate the "95th percentile" which is often used in billing. A good explanation and the original MRTG patch is now unavailable except in the web archive:

http://web.archive.org/web/20050331062012/http://www.seanadams.com/95/

The idea is to cut off 5% of the peaks and compute the average traffic based on that. It is a more faithful way of billing than just charging the average.

A more recent patch to MRTG is here: http://www.macserve.net/software/mrtg95/

Is this possible in Munin? Asking for 1.6...

Attachments

go.patch (1.4 kB) - added by insom on 08/03/10 14:26:15.
Patch against 1.4.3 to add 95th

Change History

10/27/06 10:27:28 changed by janl

  • version deleted.
  • severity changed from major to normal.

Shouldn't this be in rrd instead? To put it in munin would mean collecting the numbers into the rrd file and then writing a new rrd dataset from that --- and then graph the modified set?

Nicolai

10/27/06 11:01:04 changed by janl

Looks sort of simple 1. tune the origin rrd file to save 5 minute samples for 30 days 2. run the 95 script to generate a new rrd file to plot from

There are some reservations about how well this will work at http://www.merit.edu/mail.archives/nanog/2001-04/msg00538.html

09/25/07 21:13:27 changed by janl

  • owner changed from nobody to janl.
  • priority changed from normal to high.
  • milestone changed from Munin 1.6 to Munin 1.4.

(in reply to: ↑ description ) 11/16/07 19:51:45 changed by mozai

For what it's worth, this Perl code will give you the N-th percentile for the sum of the fields in rrd file X. AFAIK, rrdtool doesn't calculate this number automatically; it's just a very popular feature of the many tools that use rrdtool for graphing.

use RRDs;

sub percentile($;$$) {
  my ($rrdfile,$duration,$n_th) = @_;
  # duration should be 1day, 1week, 1month or 1year.
  $duration ||= "1week";
  $n_th ||= 95; # can't have 0th percentile
  my ($start,$step,$names,$data) = RRDs::fetch($rrdfile,"MAX","-s","-$duration");
  my @sums = ();
  my $timestamp = $start;
  ROWLOOP: foreach my $row (@$data) {
    my $sum = 0;
    $timestamp += $step;
    foreach my $field (@$row) {
      next ROWLOOP if (! defined $field); # skip rows that have NaN
      $sum += $field;
    }
    push(@sums,$sum);
  }
  my $which = int(scalar(@sums)*($n_th)/100);
  @sums = sort{$a<=>$b}(@sums);  # sort defaults to alpha sorting of int? wtf?
  #debug# for (my $i=0; $i<=$#sums; $i++) {print"$sums[$i]".($i==$which?'<--':'')."\n"; }
  return $sums[$which];
}

# -- main()

my $nth = 95;
$rrdfile = '/var/www/html/cacti/rra/access_switch_c2950243_traffic_in_404.rrd';

print $nth."th percentile: ".&percentile($rrdfile,"1week",$nth) ."\n";
print "Consulting the last week's traffic on c2950-24-3\n";
print "(using rrd file $rrdfile)\n";

10/20/08 17:52:53 changed by TTimo

bump

is this still being worked on?

10/22/08 01:26:30 changed by TTimo

The script provided on the ticket very likely works, I believe it's only approximate unless there is a RRA with 5 minute data and the script is modified to hit exactly only that data for the percentile computation. It is good enough for most cases.

However there is nothing setup for a plugin writer to request nth percentile on any of the data and have it drawn on the graph?

12/05/08 15:35:59 changed by janl

Looks like making such a line is supported in rrd as examplified some way down in http://oss.oetiker.ch/rrdtool/doc/rrdgraph_examples.en.html. As my munins are down due to me moving house I need to generate some rrd files to experiment with

10/27/09 23:45:18 changed by janl

  • milestone changed from Munin 1.4 to Munin 1.5.

This will not make it into 1.4

12/04/09 23:20:26 changed by janl

And we need to rewrite munin-graph before attempting this. 1.5 or 1.6.

01/18/10 13:06:02 changed by janl

  • milestone changed from Munin 1.5 to Munin 1.6.

08/03/10 14:26:15 changed by insom

  • attachment go.patch added.

Patch against 1.4.3 to add 95th

08/03/10 14:27:33 changed by insom

I've attached a patch which uses VDEFs in rrdtool 1.2 to put a 95th marker on graphs. It's rough- it applies to the positive side of any single value graph. This is kind of useful, but more options and a graceful way to handle VDEFs would be better. This suits our needs, I thought I would share.