Re: Hex conversion and configfor Qlogic FC switch
Miles Lott <[email protected]> Wed, 25 Jan 2017 17:39:05 +0000
| Newsgroups | gmane.network.mrtg.user |
|---|---|
| Message-ID | <[email protected]> |
--===============6917326021523311306== Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_011b8fa55f10466bb30f7db0eb890802EX1gulflocal_" --_000_011b8fa55f10466bb30f7db0eb890802EX1gulflocal_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Some better choices for TX, RX: TX: 1.3.6.1.3.94.4.5.1.4.16.0.0.192.221.36.107.37.0.0.0.0.0.0.0.0.1 RX: 1.3.6.1.3.94.4.5.1.5.16.0.0.192.221.36.107.37.0.0.0.0.0.0.0.0.1 These will actually show cumulative object counts for a port. The numbers = below were more specifically for tx and rx elements and leave out some othe= r types of objects. From: mrtg [mailto:[email protected]] On Behalf= Of Miles Lott Sent: Wednesday, January 25, 2017 9:11 AM To: [email protected] Subject: [mrtg] Hex conversion and configfor Qlogic FC switch I am trying to read correct values for TX, RX, and error count from a Qlogi= c SB5802 FC switch. I searched and found several examples of how to perfor= m 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 wo= rks for me. Hopefully, this will help someone: sub hextoint { use Math::BigInt; #open(STDERR, ">>/tmp/xyz.txt"); my $value =3D shift; $value =3D unpack ('H*', $value); # Value arrives packed $value =3D~ s/^0+//g; # Trim leading zeros #print STDERR "HEX INPUT: 0x$value\n"; my $val2 =3D 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 t= o 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:[email protected]|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:[email protected]|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:[email protected]|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 syst= em. Gulf Interstate Engineering Company does not accept responsibility for changes made to this electronic message or its attachments.=20 --_000_011b8fa55f10466bb30f7db0eb890802EX1gulflocal_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable <html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr= osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" = xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:= //www.w3.org/TR/REC-html40"> <head> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"> <meta name=3D"Generator" content=3D"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; font-family:"Arial",sans-serif; color:windowtext; font-weight:normal; font-style:normal; text-decoration:none none;} span.EmailStyle18 {mso-style-type:personal-reply; font-family:"Arial",sans-serif; color:#44546A; font-weight:normal; font-style:normal; text-decoration:none none;} .MsoChpDefault {mso-style-type:export-only; font-size:10.0pt;} @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=3D"edit" spidmax=3D"1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext=3D"edit"> <o:idmap v:ext=3D"edit" data=3D"1" /> </o:shapelayout></xml><![endif]--> </head> <body lang=3D"EN-US" link=3D"#0563C1" vlink=3D"#954F72"> <div class=3D"WordSection1"> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif;color:#44546A">Some better choices for TX, RX:<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif;color:#44546A"><o:p> </o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif;color:#44546A">TX: 1.3.6.1.3.94.4.5.1.4.16.0.0.192.221.36.107.37.0.0.0.= 0.0.0.0.0.1<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif;color:#44546A">RX: 1.3.6.1.3.94.4.5.1.5.16.0.0.192.221.36.107.37.0.0.0.= 0.0.0.0.0.1<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif;color:#44546A"><o:p> </o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif;color:#44546A">These will actually show cumulative object counts for a = port. The numbers below were more specifically for tx and rx elements= and leave out some other types of objects.<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif;color:#44546A"><o:p> </o:p></span></p> <div> <div style=3D"border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in = 0in 0in"> <p class=3D"MsoNormal"><b>From:</b> mrtg [mailto:mrtg-bounces+mlott=3Dg= [email protected]] <b>On Behalf Of </b>Miles Lott<br> <b>Sent:</b> Wednesday, January 25, 2017 9:11 AM<br> <b>To:</b> [email protected]<br> <b>Subject:</b> [mrtg] Hex conversion and configfor Qlogic FC switch<o:p></= o:p></p> </div> </div> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">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=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"><o:p> </o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"> sub hextoint<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"> {<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"> use Math::BigInt;<o:p></o:p= ></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"> #open(STDERR, ">>= ;/tmp/xyz.txt");<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"> my $value =3D shift;<o:p></= o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"> $value =3D unpack ('H*', $v= alue); # Value arrives packed<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"> $value =3D~ s/^0+//g; #= Trim leading zeros<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"> #print STDERR "HEX INP= UT: 0x$value\n";<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"><o:p> </o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"> my $val2 =3D Math::BigInt-&= gt;new("0x$value"); # Adding the 0x to the front was key<o:p></o:= p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"> #print STDERR "DEC OUT= PUT: $val2\n";<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"> return $val2;<o:p></o:p></s= pan></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"> }<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"><o:p> </o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">I added this to a file called conversions.pl. Then I added the f= ollowing to my .cfg file:<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">ConversionCode: /etc/mrtg/conversions.pl<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"><o:p> </o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">Finally, each port would be specified as follows:<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"><o:p> </o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"># TX FOR FC PORTS (.1 for port 0, etc.)<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">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:[email protected]|hextoint<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">MaxBytes[ip.ad.dr.ess_FC0TX]: 1000000000<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">Title[ip.ad.dr.ess_FC0TX]: FC Port 0 TX<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">PageTop[ip.ad.dr.ess_FC0TX]: <H1>FC Port 0 TX</H1><o:p></o= :p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"><o:p> </o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"># RX FOR FC PORTS<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">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:[email protected]|hextoint<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">MaxBytes[ip.ad.dr.ess_FC0RX]: 1000000000<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">Title[ip.ad.dr.ess_FC0RX]: FC Port 0 RX<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">PageTop[ip.ad.dr.ess_FC0RX]: <H1>FC Port 0 RX</H1><o:p></o= :p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"><o:p> </o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif"># Errors FOR FC PORTS<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">Target[ip.ad.dr.ess_FC0ERR]: 1.3.6.1.3.94.4.5.1.3.16.0.0.192.221.36.10= 7.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:[email protected]|hextoint<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">Options[ip.ad.dr.ess _FC0ERR]: growright, gauge, nopercent, absolute<o= :p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">YLegend[ip.ad.dr.ess _FC0ERR]: Count<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">Legend1[ip.ad.dr.ess _FC0ERR]: Count<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">MaxBytes[ip.ad.dr.ess _FC0ERR]: 1000000<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">MaxBytes[ip.ad.dr.ess_FC0ERR]: 1000000<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">Title[ip.ad.dr.ess_FC0ERR]: FC Port 0 ERR<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Arial",sans-se= rif">PageTop[ip.ad.dr.ess_FC0ERR]: <H1>FC Port 0 ERR</H1><o:p><= /o:p></span></p> </div> <hr> <font size=3D2 color=3D"#003080"> Privileged, Proprietary and/or Confidential Information may be contained in= this electronic message. If you are not the intended recipient, you shoul= d 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 syst= em.<br> <a href=3D"http://www.gie.com">Gulf Interstate Engineering Company</a> does= not accept responsibility for changes made to this electronic message or i= ts attachments.<br> </font> </body> </html> --_000_011b8fa55f10466bb30f7db0eb890802EX1gulflocal_-- --===============6917326021523311306== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ mrtg mailing list [email protected] https://lists.oetiker.ch/cgi-bin/listinfo/mrtg --===============6917326021523311306==--