[mrtg] Hex conversion and configfor Qlogic FC switch

Miles Lott mlott at gie.com
Wed Jan 25 16:11:29 CET 2017


I am trying to read correct values for TX, RX, and error count from a Qlogic SB5802 FC switch.  I searched and found several examples of how to perform the conversion from hex to decimal.  None of them worked for me.  But, I was able to combine parts of each one into the code below, which finally works for me.  Hopefully, this will help someone:

    sub hextoint
    {
        use Math::BigInt;
        #open(STDERR, ">>/tmp/xyz.txt");
        my $value = shift;
        $value = unpack ('H*', $value); # Value arrives packed
        $value =~ s/^0+//g; # Trim leading zeros
        #print STDERR "HEX INPUT: 0x$value\n";

        my $val2 = Math::BigInt->new("0x$value"); # Adding the 0x to the front was key
        #print STDERR "DEC OUTPUT: $val2\n";
        return $val2;
    }

I added this to a file called conversions.pl.  Then I added the following to my .cfg file:
ConversionCode: /etc/mrtg/conversions.pl

Finally, each port would be specified as follows:

# TX FOR FC PORTS (.1 for port 0, etc.)
Target[ip.ad.dr.ess_FC0TX]: 1.3.6.1.3.94.4.5.1.6.16.0.0.192.221.36.107.37.0.0.0.0.0.0.0.0.1&1.3.6.1.3.94.4.5.1.6.16.0.0.192.221.36.107.37.0.0.0.0.0.0.0.0.1:public at ip.ad.dr.ess|hextoint
MaxBytes[ip.ad.dr.ess_FC0TX]: 1000000000
Title[ip.ad.dr.ess_FC0TX]: FC Port 0 TX
PageTop[ip.ad.dr.ess_FC0TX]: <H1>FC Port 0 TX</H1>

# RX FOR FC PORTS
Target[ip.ad.dr.ess_FC0RX]: 1.3.6.1.3.94.4.5.1.7.16.0.0.192.221.36.107.37.0.0.0.0.0.0.0.0.1&1.3.6.1.3.94.4.5.1.7.16.0.0.192.221.36.107.37.0.0.0.0.0.0.0.0.1:public at ip.ad.dr.ess|hextoint
MaxBytes[ip.ad.dr.ess_FC0RX]: 1000000000
Title[ip.ad.dr.ess_FC0RX]: FC Port 0 RX
PageTop[ip.ad.dr.ess_FC0RX]: <H1>FC Port 0 RX</H1>

# Errors FOR FC PORTS
Target[ip.ad.dr.ess_FC0ERR]: 1.3.6.1.3.94.4.5.1.3.16.0.0.192.221.36.107.37.0.0.0.0.0.0.0.0.1&1.3.6.1.3.94.4.5.1.3.16.0.0.192.221.36.107.37.0.0.0.0.0.0.0.0.1:public at ip.ad.dr.ess|hextoint
Options[ip.ad.dr.ess _FC0ERR]: growright, gauge, nopercent, absolute
YLegend[ip.ad.dr.ess _FC0ERR]: Count
Legend1[ip.ad.dr.ess _FC0ERR]: Count
MaxBytes[ip.ad.dr.ess _FC0ERR]: 1000000
MaxBytes[ip.ad.dr.ess_FC0ERR]: 1000000
Title[ip.ad.dr.ess_FC0ERR]: FC Port 0 ERR
PageTop[ip.ad.dr.ess_FC0ERR]: <H1>FC Port 0 ERR</H1>


--------------------------------------------------------------------------------
Privileged, Proprietary and/or Confidential Information may be contained in
this electronic message.  If you are not the intended recipient, you should
not copy it, re-transmit it, use it or disclose its contents, but should
kindly return to the sender immediately and delete your copy from your system.
Gulf Interstate Engineering Company does not accept responsibility for
changes made to this electronic message or its attachments. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.oetiker.ch/pipermail/mrtg/attachments/20170125/5a109ecf/attachment.html>


More information about the mrtg mailing list