[mrtg] Draw link load percentage

Steve Shipway s.shipway at auckland.ac.nz
Wed Jan 23 21:50:07 CET 2008


> It actually turned out to me much easier with plain MRTG.
> 
> Target[foo]: link at 1.2.3.4 * 100 / link's maxbytes
> # link / maxbytes * 100 won't work probably due to integer division

Of course this works as well, but you have to remember that the values
stores in the database will now be percentages whereas the other way,
you store the actual traffic (so you can see the data displayed in
either way).  Also, if you autogenerate your .cfg files, then the first
way you just need to add a '--global routers.cgi*Options[^]:aspercent'
to the cfgmaker directive whereas the second way you will need to edit
the cfgmaker script or use a template.

Having the calculation done on the Target line will run the calculation
*before* storing in the .log or .rrd file.  A Factor[] line, or the
various routers2 options, are performed at display time.  As you
mention, this can cause problems with .log files as they do not handle
non-integers very well.

Which way you use really depends on your requirements - both give you
different benefits and disadvantages.  We try here - as far as possible
- to store the 'raw' data and display it 'cooked', so in the future we
can change the cooking recipe if required...

One time when the Target[] line is the best location for the calculation
is if the MaxBytes changes regularly, such as disk space usage (when you
might increase disk space).  However, in this case, routers2 supports
'dorelpercent' which displays 'in' as a percentage of 'out', so we store
the disk size in 'out' and the disk usage in 'in' and it still works.

Steve



More information about the mrtg mailing list