manage_DLINK_SNMP_behaviour perl code
by idleloop (idleloop -AT- yahoo.com), 20070729

D-LINK DSL-G624T (and probably others), behaves in a very strange mode:
as soon as a counter reaches 999999999 (1GByte), it start counting in
increments of 10 Bytes, starting in 100000000 (10**8 instead of 10**9).
This function tries to patch this behaviour, returning the correct value
(multiplying by 10 if it's required), aided by a txt file which logs 
previous values for each counter...

-------------------------------------------------------------------------------
INSTRUCTIONS:

1. place "manage_DLINK_SNMP_behaviour.pl" file in the same directory as your
"mrtg" file (it's typically in "bin" directory under your mrtg installation).

2. Now, if you use mrtg v2.15.2 you can just replace your mrtg file with the
one included in this tgz. In other case, you must add two lines in your 
"mrtg" file. Open it with a text editor. 
As "mrtg" file change between versions, there's no fix lines... so
read 2a and 2b, (u can also take a look to the two *diff files included).
2a.
require ('./manage_DLINK_SNMP_behaviour.pl'); # idleloop, 20070729
This previous line at the beginning of the file, for example after this line:
use locales_mrtg "0.07";

2b.
($inlast,$outlast)=@{&manage_DLINK_SNMP_behaviour($router,$inlast,$outlast)}; # idleloop, 20070729
this line must be *after* this line has been executed:
getcurrent(\@target, $router, \%rcfg, \%cfg);
for example, just before:
            if ($cfg{'logformat'} ne 'rrdtool') {

3. that's all. Now, this script just need to be able to write in the directory
where it is. It'll create a tiny file named:
manage_DLINK_SNMP_behaviour.log
with data needed in order to handle the D-LINK DSL-G624T behaviour.
-------------------------------------------------------------------------------

NOTE: obviously, this script doesn't work if mrtg starts *after* the router
reaches its 1GByte mark in any counter... in this case, open log file:
manage_DLINK_SNMP_behaviour.log
and just multiply by 10 the desired counter, and it'll work.

-------------------------------------------------------------------------------

I'm not sure if this could alse be achieved without any additional log file,
just reading the log files mrtg creates. My tests didn't succes 'cause it
seemed that mrtg files were written before the call to this function.
As this runs perfect, and I hadn't much time, I left this as it is.

A question that arises is what will occur when the router reaches again
its 10**9 value? (=> 10GByte transmitted) ... if someone knows the answer,
let me know, in order to accordingly modify this script ;)

-------------------------------------------------------------------------------

manage_DLINK_SNMP_behaviour.20070729.tgz

contains:

diff.mrtg.2.9.22.txt			diff between original and modified mrtg
diff.mrtg.2.15.2.txt			for these two different versions
manage_DLINK_SNMP_behaviour.pl		my perl code
mrtg					mrtg 2.15.2 already modified
readme.txt				this file
