LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-26-2011, 04:07 AM   #1
rahul_dubeyin
Member
 
Registered: Apr 2011
Posts: 34

Rep: Reputation: 12
Duplex setting of switch port


Dear All,

Can any one let me know how to get duplex setting of cisco switches using Perl script or SNMP?

let me re-phrase it.
I have 150 switches in offices all over the world. I want to get duplex setting of all the ports of all the switches. I am looking for SNMP which is easier however I have a Perl script which can login to every switch and take backup of switch which can be make to get the data though requires lots of workaround and time.

Thanks,
Rahul

Last edited by rahul_dubeyin; 05-26-2011 at 04:27 AM.
 
Old 05-31-2011, 05:24 AM   #2
rahul_dubeyin
Member
 
Registered: Apr 2011
Posts: 34

Original Poster
Rep: Reputation: 12
Can any one help?
 
Old 05-31-2011, 11:23 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by rahul_dubeyin View Post
Can any one help?
Help with what?? You've asked a vague question, and hint at the fact you've already got a solution.

If you've got a script to log into all your switches, then you need to modify it. Figure out what SNMP string you need to query to find out the duplex settings, and put it in your script. Examine the output, and write it out as you wish. Not much more to it.

If you have a SPECIFIC problem, post it along with the code you've written. Otherwise, there's not much we can help with.
 
Old 06-01-2011, 05:21 AM   #4
rahul_dubeyin
Member
 
Registered: Apr 2011
Posts: 34

Original Poster
Rep: Reputation: 12
Quote:
Originally Posted by TB0ne View Post
Help with what?? You've asked a vague question, and hint at the fact you've already got a solution.

If you've got a script to log into all your switches, then you need to modify it. Figure out what SNMP string you need to query to find out the duplex settings, and put it in your script. Examine the output, and write it out as you wish. Not much more to it.

If you have a SPECIFIC problem, post it along with the code you've written. Otherwise, there's not much we can help with.
Hi, thanks for the reply. May be my English is so poor that I am not able to convey you what I am looking for.
I was looking for the MIB which can provide duplex setting. There has to be a specific MIB which tell you that and I was looking for its name.
The script I was talking about is not SNMP based but telnet based which login to switch and run a command to get the duplex setting.

I hope I made clear this time.
 
Old 06-01-2011, 05:28 AM   #5
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by rahul_dubeyin View Post
I was looking for the MIB which can provide duplex setting.
Start here: http://www.cisco.com/public/sw-cente...mtk/mibs.shtml

See if you can find the MIB you seek, and then let us know if you have additional questions.
 
Old 06-01-2011, 10:10 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by rahul_dubeyin View Post
Hi, thanks for the reply. May be my English is so poor that I am not able to convey you what I am looking for.
I was looking for the MIB which can provide duplex setting. There has to be a specific MIB which tell you that and I was looking for its name.
The script I was talking about is not SNMP based but telnet based which login to switch and run a command to get the duplex setting.

I hope I made clear this time.
Providing clear details is always good.

You mentioned Perl. The Net:SNMP module is what I'd look for in CPAN, if I were you. Using Telnet (especially over a WAN to your switches), is a dangerous thing. Since what you're after is one particular setting, try something like snmpwalk to identify what you're looking for. The man pages can help you, but it'll be something like:
Code:
snmpwalk -v1 -c public 11.22.33.44 > switch.txt
That way, you'll see EVERYTHING available on that switch in the text file. Look for the duplex setting in there, and it'll have an OID associated with it. It may already be identified under the system MIB, since it's a switch. Take a look. Once you find it, script accordingly. You've already got the
switch names and IP addresses. Loop through them in your perl script, and read the info you got from the snmpwalk. Check the string to see what the duplex is, and output it however you wish.
 
1 members found this post helpful.
Old 06-02-2011, 04:56 AM   #7
rahul_dubeyin
Member
 
Registered: Apr 2011
Posts: 34

Original Poster
Rep: Reputation: 12
The system MIBs don't provide duplex settings. But now I have found the MIB name and for every one benefit mentioning here.
MIB Name = CISCO-STACK-MIB

and install all the dependencies from below mentioned link.
http://tools.cisco.com/Support/SNMP/...ISCO-STACK-MIB


These MIBs need to copied to /usr/share/snmp/mibs and then run this command.

snmpwalk -v1 -c public IP portDuplex


Thanks for the help all of you
 
1 members found this post helpful.
Old 06-02-2011, 03:08 PM   #8
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by rahul_dubeyin View Post
The system MIBs don't provide duplex settings. But now I have found the MIB name and for every one benefit mentioning here.
MIB Name = CISCO-STACK-MIB

and install all the dependencies from below mentioned link.
http://tools.cisco.com/Support/SNMP/...ISCO-STACK-MIB


These MIBs need to copied to /usr/share/snmp/mibs and then run this command.

snmpwalk -v1 -c public IP portDuplex
Thanks for the help all of you
Thank you for providing a follow-up, and posting a very helpful link to others who are looking to solve this problem.

If you're going to script it via Perl, the Net:SNMP module will help. Or, you could (and I know I'll get flamed from other programmers), use a system call to use the snmpwalk command, and read the output.
 
1 members found this post helpful.
Old 06-03-2011, 04:41 AM   #9
rahul_dubeyin
Member
 
Registered: Apr 2011
Posts: 34

Original Poster
Rep: Reputation: 12
Quote:
Originally Posted by TB0ne View Post
Thank you for providing a follow-up, and posting a very helpful link to others who are looking to solve this problem.

If you're going to script it via Perl, the Net:SNMP module will help. Or, you could (and I know I'll get flamed from other programmers), use a system call to use the snmpwalk command, and read the output.
I did it via bash script. If any one require that script I can provide that.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I manually set my cisco switch to 100mpbs full duplex? abefroman Linux - Networking 5 01-20-2006 09:35 AM
setting up com port for serial connection to monitor network switch help murf562 Linux - Hardware 1 10-30-2004 09:46 AM
etho: setting 3c5x9/3c5x9b half-duplex mode if-port: 0, sw-info: 1321 lindab_tsp Linux - Networking 1 08-08-2003 06:45 AM
etho: setting 3c5x9/3c5x9b half-duplex mode if-port: 0, sw-info: 1321 lindab_tsp Linux - Networking 0 08-06-2003 06:35 AM
Best 10/100 Mbps 24 port switch for full duplex with Linux joeschmoe Linux - Networking 2 11-10-2001 09:07 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration