[mrtg] I give up, how do you make mrtg work?

Jay Hennigan jay at west.net
Sat Mar 20 21:26:33 CET 2010


On 3/20/10 12:29 PM, Geoff Sweet wrote:
> For two days I have fought and fought to make MRTG produce graphs that make any kind of sense and I am now stuck.  I have basically built a mock-up so as to remove any unknown aspect of fetching data from my server.
> 
> I started with a small script that emulates exactly the data I am getting. I am using bwm-ng on OpenBSD to give me rate values for the network interface that is in bytes/sec.  I mocked a perl script up to produce that output for now:
>
> and the output looks like this:
> 
> # perl /usr/local/wemade/get_fw_bw.pl 
> 2906330
> 1127083
> 0
> 0
> 
> I added in the rand part so I could see some small fluctuation.  But 2905701 in bytes/sec should be about (2905701 X 8) 23245608 bits/sec or about 23Mb/sec.  I feed that in via my mrtg config:

By default, MRTG treats input values as an incrementing counter of bytes
transferred since last reset or reboot.  That's what the router SNMP
provides.

What this means is that MRTG stores the value it gets.  Five minutes
later it pulls the new value, subtracts its stored value, treats the
difference as the number of bytes transferred, and then replaces the
stored value with the latest one.

You can either modify your perl script to increment the values by (bytes
* 300 seconds +/- randomization) each time, or you can tell MRTG to
treat the input as a value and not a counter by using the "absolute"
option.

Output is shown in bytes unless you specify "bits" as an option.

Using your present script, try:

Options[fw_total]: growright,bits,absolute

and see if the output makes more sense.

RTFM regarding "absolute" and "gauge" options here, this will help when
working with scripts or other non-standard input values:

http://oss.oetiker.ch/mrtg/doc/mrtg-reference.en.html

> HtmlDir: /var/www/html/prodstats/firewall
> ImageDir: /var/www/html/prodstats/firewall
> LogDir: /var/lib/mrtg
> ThreshDir: /var/lib/mrtg
> Title[fw_total]: Firewall Total Bandwidth
> PageTop[fw_total]: <H1>Firewall Total Bandwidth</H1>
> Options[fw_total]: growright
> Target[fw_total]: `/usr/bin/perl /usr/local/wemade/get_fw_bw.pl`
> YLegend[fw_total]: Bandwidth
> MaxBytes[fw_total]: 32768000
> 
> and after now several iterations my chart says
> 
>  Max  	Average  	Current
> In 	8.0 B/s (0.0%) 	9.0 B/s (0.0%) 	9.0 B/s (0.0%)
> Out 	12.0 B/s (0.0%) 	12.0 B/s (0.0%) 	12.0 B/s (0.0%) 
> 
> and the logfile looks like this:
> 
> # head /var/lib/mrtg/fw_total.log 
> 1269113161 2906169 1126931
> 1269113161 5 5 5 5
> 1269113102 11 5 11 5
> 1269113100 8 12 158 105
> 1269112800 0 0 0 0
> 1269112500 0 0 0 0
> 1269112200 0 0 0 0
> 1269111900 0 0 0 0
> 1269111600 0 0 0 0
> 1269111300 0 0 0 0

--
Jay Hennigan - CCIE #7880 - Network Engineering - jay at impulse.net
Impulse Internet Service  -  http://www.impulse.net/
Your local telephone and internet company - 805 884-6323 - WB6RDV



More information about the mrtg mailing list