<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Arial",sans-serif;
color:windowtext;
font-weight:normal;
font-style:normal;
text-decoration:none none;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">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:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"> sub hextoint<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"> {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"> use Math::BigInt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"> #open(STDERR, ">>/tmp/xyz.txt");<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"> my $value = shift;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"> $value = unpack ('H*', $value); # Value arrives packed<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"> $value =~ s/^0+//g; # Trim leading zeros<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"> #print STDERR "HEX INPUT: 0x$value\n";<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"> my $val2 = Math::BigInt->new("0x$value"); # Adding the 0x to the front was key<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"> #print STDERR "DEC OUTPUT: $val2\n";<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"> return $val2;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">I added this to a file called conversions.pl. Then I added the following to my .cfg file:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">ConversionCode: /etc/mrtg/conversions.pl<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">Finally, each port would be specified as follows:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"># TX FOR FC PORTS (.1 for port 0, etc.)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">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@ip.ad.dr.ess|hextoint<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">MaxBytes[ip.ad.dr.ess_FC0TX]: 1000000000<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">Title[ip.ad.dr.ess_FC0TX]: FC Port 0 TX<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">PageTop[ip.ad.dr.ess_FC0TX]: <H1>FC Port 0 TX</H1><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"># RX FOR FC PORTS<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">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@ip.ad.dr.ess|hextoint<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">MaxBytes[ip.ad.dr.ess_FC0RX]: 1000000000<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">Title[ip.ad.dr.ess_FC0RX]: FC Port 0 RX<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">PageTop[ip.ad.dr.ess_FC0RX]: <H1>FC Port 0 RX</H1><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"># Errors FOR FC PORTS<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">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@ip.ad.dr.ess|hextoint<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">Options[ip.ad.dr.ess _FC0ERR]: growright, gauge, nopercent, absolute<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">YLegend[ip.ad.dr.ess _FC0ERR]: Count<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">Legend1[ip.ad.dr.ess _FC0ERR]: Count<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">MaxBytes[ip.ad.dr.ess _FC0ERR]: 1000000<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">MaxBytes[ip.ad.dr.ess_FC0ERR]: 1000000<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">Title[ip.ad.dr.ess_FC0ERR]: FC Port 0 ERR<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">PageTop[ip.ad.dr.ess_FC0ERR]: <H1>FC Port 0 ERR</H1><o:p></o:p></span></p>
</div>
<hr>
<font size=2 color="#003080">
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.<br>
<a href="http://www.gie.com">Gulf Interstate Engineering Company</a> does not accept responsibility for changes made to this electronic message or its attachments.<br>
</font>
</body>
</html>