ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.