[mrtg] Re: Decimals from monitoring script
Grendel
grendel at interq.ad.jp
Thu Mar 29 04:02:15 MEST 2001
Hi,
MRTG seems to have been zeroing out integers only since sometime after
it started supporting rrdtool. I found this out the hard way when I
moved a percentage-computing script from a machine running 2.8.9 to
another using 2.9.4 and it suddenly flatlined. 2.8.9 dropped the integer
portions of numbers, while 2.9.4 would pass them straight through to
rateup which in turn got confused by the decimal point and set them to
zero. I did consider switching to rrdtool but we need the running stock
of image files.
To get around this, I edited the mrtg Perl executable itself so that
unless the logformat were set to rrdtool, it took only the integer
portion of numbers. Unfortunately I haven't yet gotten around to
rewriting this mod according to the official contribution guidelines.
For now, I'll give instructions on where I went and what I did.
I could give line numbers, but then again I don't know what version
you're using. As a bare minimum, you need to look for the line that
reads "abort, if the router is not responding." It should be the only
line that contains the word "abort." After that is a line that reads
"next unless defined $inlast and defined $outlast;". And after that, you
need to add something like the following line or something simpler if
you prefer:
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));
}
Beware of the carriage returns used to split up the above. If you're
not as anal as I've been here you can just say for example $inlast =
int($inlast) and $outlast = int($outlast).
Attached is the full text of what I added to the mrtg I'm using here.
Again, I'd put it in official contribution format but the whole
company's moving buildings this weekend.
Best regards,
James Overbeck
interQ
Tokyo, Japan
"Paul C. Williamson" wrote:
>
> Henrik,
>
> MRTG only does integers, therefore other than multiplying the value by
> 10 or 100, you'll never get the number you are looking for. You may be
> able to play with the kMG option to get the correct display. Switch to
> RRDTool to get not only decimals, but also negative numbers as well!
>
> Paul
>
> >>> Henrik Larsson <henrik at larsson.net> 03/28/01 03:13PM >>>
>
> Hello,
>
> I am trying to monitor a special temperature device with help of MRTG. I
> have programmed my own little script which perform this, but MRTG doesn'ta
> ccept the values that are given from my script.
>
> My script reports the temperature with one decimal like "0.3". I have madea
> workaround with negative numbers, so that is allready fixed.
>
> Can I in some way get MRTG to be nice to numbers with one decimal or do In
> eed to do some kind of multiplication in my script (like X * 10) too foolM
> RTG and then divide the result with some config parameter (like X / 10) inm
> rtg.cfg so I get the correct result in my graph in the end. But it seemsl
> ike it isn't possible to divide in MRTG...just do multiplication...
>
> Thanks for your help
>
> Regards,
>
> Henrik Larsson
> henrik at larsson.net
> Sweden
>
> --
> 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
-- Attached file removed by Listar and put at URL below --
-- Type: text/plain
-- Size: 1k (1451 bytes)
-- URL : http://www.ee.ethz.ch/~slist/pantomime/patch.txt
--
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