[mrtg] Re: MRTG losing Bytes in Octet string

Rene Buechler rene.buechler at zurich.com
Wed Jun 9 12:52:14 MEST 2004





After spending some time with the debugger, I've found add. hex bytes which
makes problems
in the mrtg module and ConversionCode. Now I have a workaround.
I commented out the three lines of code in module mrtg: 1934 - 1936. These
3 lines will remove
the 0x0a and the 0x0d from the octet string.
After this change, I had still problems with the eval function at line
1944.
Byte 0x0d will trigger the eval routine and is not executing my
ConversionCode. Byte 0x9a is not
triggering the eval routine neither my ConversionCode. I've now hardcoded
my ConversionCode
directly into the mrtg module and is now running fine.
I was not abel to change the mrtg script in a way that my subroutine will
be executed without the eval function.

Maybe someone has a better solution?

My changes and Conversioncode in the mrtg module:

  # have some cleanup first, it seems that some agents
  # are adding newlines to what they return
  #    map{ $_ =~ s/\n|\r//g if defined $_ } @res;
  #    map{ $_ =~ s/^\s+//g if defined $_ } @res;
  #    map{ $_ =~ s/\s+$//g if defined $_ } @res;

 # Convert in and out values to integers with a user-defined subroutine
 # specified by the Conversion target key
    if( $target->{ Conversion } ) {
        foreach my $ri( 0..1 ) {
            next unless defined $res[ $ri ];
                  my $hex_string = unpack("H*", $res[ $ri ]);
# build hex string
                  my $upper_hex_string = substr($hex_string,0,8);
                  my $lower_hex_string = substr($hex_string,8,8);
                  # build numeric value from the two substrings
                  $res[ $ri ] = ((hex($upper_hex_string)) * 16**8) +
hex($lower_hex_string);

#            my $exp = "&MRTGConversion::$target->{ Conversion }( '$res[
$ri ]' )";
#            $res[ $ri ] = eval $exp;
#            warn "WARNING: evaluation of \"$exp\" failed\n$@\n" if $@;
        }
    }



> Hi
> I'm using MRTG 2.10.13 on a Windows NT workstation.
> I'm scanning on our Ficon Directors FC/9000 (CNT) the Rx- and TxFrames to
> check the utilisation of each FC-Port.
> These Directors will give me back a 64-Bit counter value as an octet
> string.
> To convert this octet string I'm using the option ConversionCode and a
> small perl script.
> Now I have seen, that some values from the counters are wrong. I've
found,
> that when inside an octet string is a Hex Byte with 0x0a or 0x0d these
> bytes gets lost. In this case, MRTG will handover to my subroutine only
> seven Bytes instead of 8 Bytes. I made a lot of tests and testet each hex
> code from 00 ... FF. Every hex code is ok except the two ones with Hex
> codes 0x0a and 0x0d which gets lost.




--
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