[mrtg-developers] rateup performance increase & minor bug patch

Do Jong Gwan daker at metri.re.kr
Tue Nov 7 03:57:47 MET 2000


Hi, MRTG developers!

I'm currently using MRTG.
I've found some problems in rateup.c.

There is still a problem in MRTG 2.9.4.
I've fixed two problems.

Below is a source from line 359 of rateup.c.
---------------------------------------------------------------------
digits = 0;
    {
    double number = (double)maxv_q;
/*
       while (number/(double) kilo >= (double)kilo && digits<kMGnumber*3) {
*/
       while (number >= (double)kilo && digits<kMGnumber*3) {
          number /= (double) kilo;
          digits += 3;
       }
       sca_max_q = (double) ( (int) (  ( (double)100.*(double)number )/
                 (pow((double)10.,(double)(int)(log10((double)number))))
                +(double)9.999) / (int)10) /(double)10
                *(pow((double)10.,(double)(int)(log10((double)number))));
    }
----------------------------------------------------------------------

I've changed as follows.
----------------------------------------------------------------------
digits = 0;
    {
    double number = (double)maxv_q;
/*
       while (number/(double) kilo >= (double)kilo && digits<kMGnumber*3) {
*/
       while (number >= 1000. && digits<kMGnumber*3) {
          number /= 1000.;
          digits += 3;
       }
/*       sca_max_q = (double) ( (int) (  ( (double)100.*(double)number )/
                 (pow((double)10.,(double)(int)(log10((double)number))))
                +(double)9.999) / (int)10) /(double)10
                *(pow((double)10.,(double)(int)(log10((double)number)))); */
    }
-----------------------------------------------------------------------

1.
I've commented out sca_max_q calculation.
At line 410, sca_max_q is assigned to another value.
Between these lines, sca_max_q is never used.
So I commented out.
This calculation has many mathematical functions,
So I think this commenting out is useful for heavy loaded MRTG system.

2.
I've changed (double)kilo to 1000.0.
This routime only determines kMG unit postfix in GIF graph.
The real values are calculated below this source code.
If someone( especially for me ) uses kMG value of 1024 in configuration
file.
There is some problem when the last devided value( variable number in source
code)
exist between 1000 and 1024.
In this case, graph's Y labels are somewhat strange.
For example, gif graph writes 1.1M for real 1.1G Y labels.
So I fixed it.
Now I can get the right Y lablel of MRTG generated gif graphs for the rare
case.

Have a nice day.


--
Unsubscribe mailto:mrtg-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:mrtg-developers-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/mrtg-developers



More information about the mrtg-developers mailing list