[mrtg] Re: problem with percentage displays
Grendel
grendel at interq.ad.jp
Wed Apr 4 18:40:00 MEST 2001
Hello,
I had the same problem when moving a percentage script from 2.8.9 to
2.9.4. Below I've pasted the change I've made to every copy of mrtg I've
used since then to tell it to round non-integers unless it's using
rrdtool. Please feel free to use whatever rounding algorithm you like.
All that's important is the location, so I've included a couple lines of
context from either end. This is the only place in the perl executable
where the word "abort" appears, so it should be easy enough to find.
Usual cautions about my mail client splitting up lines. I've submitted a
patch according to the official contribution guidelines, and Tobias was
replied, so I believe it (or something close enough) will be included in
the next release.
By the way, if your graphs are flatlining, then your log files contain
all zeros for the flat portions anyways, except for the first line which
has a time stamp followed by two integers. Not sure exactly how you're
calculating the percentages, but I'm guessing that they happen to work
out to integers for the non-flatline portions.
In my situation, we need the running stock of images. And once when I
tried switching from rateup to rrdtool for a group of about 30
catalysts, CPU usage (also solaris) took a jump up, so I switched back.
But on the other hand, rrdtool would allow you to track the non-integer
parts, which might be important if your percentages are low.
Best regards,
James Overbeck
GMO - http://www.gmo.co.jp/
Tokyo, Japan
> #abort, if the router is not responding.
> next unless defined $inlast and defined $outlast;
>
> # Fix to integer value, just in case we're not using rrdtool
> # and we're doing Target math that results in non-integer
> # values.
>
> if ($cfg{'logformat'} ne 'rrdtool') {
> $inlast = (0.5 > abs($inlast - int($inlast)) ) ? int($inlast) : int($inlast) + int($inlast/abs($inlast));
> $outlast = (0.5 > abs($outlast - int($outlast)) ) ? int($outlast) : int($outlast) + int($outlast/abs($outlast));
> }
>
> # Rateup has never been able to deal with non-integer target
> # values, and mrtg's response to non-integer target values
> # has never been officially defined it seems. Yet somewhere between
> # version 2.8.12 and 2.9.4, getcurrent changed from using the following parser:
> # $inlast = sprintf("%.0f",eval($$rcfg{target}{$rou}));
> # to using the following parser:
> # $inlast = eval("my \$mode='_IN_';$$rcfg{target}{$rou}");
> # The former automatically drops the non-integer part of the response,
> # while the latter keeps it. Keeping it and passing it to rateup
> # confuses rateup, which looks at the non-integer, says "Huh?",
> # and turns it into a zero. Instead of dropping the non-integer
> # part I chose to round it to the nearest integer.
> #
> # James Overbeck Jr. grendel at interq.ad.jp
> # 2000/12/04, v.2.9.4
> # 2001/03/27, v.2.9.10
>
> my ($maxin, $maxout, $maxpercent, $avin, $avout, $avpercent,
> $cuin, $cuout, $cupercent);
--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive http://www.ee.ethz.ch/~slist/mrtg
FAQ http://faq.mrtg.org Homepage http://www.mrtg.org
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the mrtg
mailing list