[aklug] Re: MySQL sorting alphanumerics

From: James Zuelow <James_Zuelow@ci.juneau.ak.us>
Date: Mon Apr 05 2010 - 08:24:09 AKDT

I think I will end up using a separate column to sort with, using the switc=
h's interface ID.

I did not give enough information in my original post, so here's some backg=
round.

I'm not combining two different types of data that can be separated out. H=
ere's a snippet of information from four different switches:

(I apologise in advance -- I know the list settings are really going to man=
gle this output what with the =3D3D stuff, etc.)

An HP Procurve:
.1.3.6.1.2.1.31.1.1.1.1.117 =3D STRING: "E21"
.1.3.6.1.2.1.31.1.1.1.1.118 =3D STRING: "E22"
.1.3.6.1.2.1.31.1.1.1.1.119 =3D STRING: "E23"
.1.3.6.1.2.1.31.1.1.1.1.120 =3D STRING: "E24"

Also a Procurve:
.1.3.6.1.2.1.31.1.1.1.1.12 =3D STRING: "12"
.1.3.6.1.2.1.31.1.1.1.1.13 =3D STRING: "13"
.1.3.6.1.2.1.31.1.1.1.1.14 =3D STRING: "14"

Also a Procurve (but one of the brain dead 1800 series -- stay away!):
.1.3.6.1.2.1.31.1.1.1.1.105 =3D STRING: "Port #5"
.1.3.6.1.2.1.31.1.1.1.1.106 =3D STRING: "Port #6"
.1.3.6.1.2.1.31.1.1.1.1.107 =3D STRING: "Port #7"
.1.3.6.1.2.1.31.1.1.1.1.108 =3D STRING: "Port #8"

Cisco:
.1.3.6.1.2.1.31.1.1.1.1.22 =3D STRING: "Fa0/21"
.1.3.6.1.2.1.31.1.1.1.1.23 =3D STRING: "Fa0/22"
.1.3.6.1.2.1.31.1.1.1.1.24 =3D STRING: "Fa0/23"
.1.3.6.1.2.1.31.1.1.1.1.25 =3D STRING: "Fa0/24"

So you see the "12" and "E24" really are the same data. Also I can't assum=
e the strings will have either a number or a letter and a number. Some of =
the output even includes spaces!

What I can use is the last set of digits in the returned OID. On most of t=
he Procurve switches you can see that the last set of digits is the physica=
l number of the interface. The first example from a 5406 shows that there =
are 120 physical interfaces on the switch. The second example is from a 25=
12 -- interfaces 13 and 14 are actually blanks for holding GBICs, so there =
is no guarantee that the interfaces are actually present. However the HP 1=
800 starts its numbering from 101, and the Cisco number is actually one gre=
ater than the physical port.

That means I can't use that information for a human being. I'm not going t=
o ask one of my co-workers to count out to interface 93 on the 5406 to iden=
tify a port, and trying to figure out if the numbering starts at one (HP), =
two (Cisco), or 100 (HP 1800 series) seems like quite a bit of work for ver=
y little return.

The nifty thing is that I've built up several cgi scripts to expose the dat=
a via web browser. That means I can control what the user sees, barring th=
em firing up a SQL client of some sort and building their own queries. I d=
on't have any cgi scripts that list ports from more than one switch. You c=
an see results from more than one switch if you search for an IP address or=
 hostname, but those are sorted by the IP or hostname. When you just get a=
 list of "what is on what port" there is only one switch involved.

So the tail end of the OID will still work for that -- whether it is 1-2-3 =
or 333-334-335 is irrelevant, it will still let me sort the data as it appe=
ars that all of the switches in my environment increment the OID in the sam=
e direction the switch names increment.

All it means is that I have to add a field in the table, and change an arra=
y to a hash in the Perl scripts that populate the database or query the dat=
abase for a user's browser.

It's a pretty simple solution, but last week I just was not seeing it. Som=
etimes lots of eyes are needed.

Cheers!

James Zuelow
Network Specialist
City and Borough of Juneau MIS (907)586-0236=20

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Mon Apr 5 08:24:33 2010

This archive was generated by hypermail 2.1.8 : Mon Apr 05 2010 - 08:24:33 AKDT