Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find number of ports

Status
Not open for further replies.

JJ1

Programmer
Apr 19, 2001
104
0
0
GB
Hi All,

You probably hear this everyday, but "I'm a newbie to SNMP." Now we've got that confession over with, I have a small project which I was hoping someone could spend a few minutes helping me with please:

My boss wants a bash script (or Java app) to find the total number of ports on our Network Switches (so we can tell this to Cisco for our maintainance contract).

We use HPOpenView in our organisation, and I've managed to locate something called "snmpwalk". Now, as soon as I try a command in UNIX such as "snmpwalk my_2924_switch" I get an error complaining of a missing 'hpovlib.so' file (or something similar). Any ideas anyone? Is this normal? Would it affect any attempt to write a script to find the total number of switch ports?

Basically I have 2 further problems, as follows:
[red]
1. How do I 'trawl' the network to find all the switches, so that I can then use SNMP to find how many ports each has?

2. When I have a list of switches, how do I know what SNMP query string to use? mgmt.interfaces.x.x.x.x?? And to which command would this parameter be passed (I don't seem to have snmpget, just [a faulty] snmpwalk)?
[/red]
I appreciate that everyone has other things to do besides answer these questions, but if you take the time. Thank you very much ;-)

James.
 
hi James,
If snmpwalk is running properly....there are two more things in ur problem..
1. Checking out wether a system is a Switch or not
2. If so how many interfaces that switch have..

the oid 'system.sysObjectID.0' will give u the default oid for that switch...in the sence this is the root oid for that device...

Because u are clear with they are all Cisco switches..first please goto Cisco site and search for device specific mibs..
and get the sysObjectID for all types of switches..so in your network if any device's system.sysObjectID.0 belongs to the oid which is available...then it is a switch...
And now we can easily get the number of ports on that switch by doing snmpwalk on .1.3.6.1.2.1.2.1 oid(ifNumber). This will return total number of interfaces on that device..which is required...

but i am sorry...please go and collect all the switch types and their default oids (system.sysObjectID) from Cisco site..
thanks,
sireesh

 
James,

How about approaching this from inside your Cisco environment?

This is all asuming that you have command line access to the Cisco switches.

Telnet to any switch and give it the enable password.

To find what switches are on that network, use the "show cdp neighbors" CLI command. Add the "detail" option and it will even give you the IP address of its neighbor switches. This gives you a wealth of information about each switch. You can then gather how many ports each switch has buy doing a "show module" command at the switch.

You will need to do this in each VLAN / subnetwork since cdp packets don't cross broadcast domains.

HTH,
Patrick

Patrick Bartkus, CCNP, CNX, SCM Sr. Network Engineer
GA Dept of Labor IT Network Services
If truth were not absolute, how could there be justice?
 
Alternatively you can have a look at solarwinds network and performance tools. query what devices you have, how many and what ports are in use. there are plently of other bells and whistles... check it out.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top