Sponsored Content
Top Forums Shell Programming and Scripting using if to identify proper mib for use with a cisco switch Post 302262590 by Christoph Spohr on Friday 28th of November 2008 04:46:25 AM
Old 11-28-2008
That's is pretty much what i wrote. Replace ($)line with ($)ip:

Code:
while read ip
do
    output=$(snmpwalk -v 3 -u user -l AuthNoPriv -A password "$ip" "$3550mib")
    [[ $output =~ No]] snmpwalk -v 3 -u user -l AuthNoPriv -A password "$ip" "$3560mib") || snmpwalk -v 3 -u user -l AuthNoPriv -A password "$ip" "$3550mib")
done < nmapres

But most probably snmpwalk returns an exit code if the program failed. So you could simply run it and if the exit code ist not 0, then it failed for whatever reason and you have to run it again.

So this should work, too:

Code:
while read ip
do
    snmpwalk -v 3 -u user -l AuthNoPriv -A password "$ip" "$3550mib"
    [[ $? -ne 0]] && snmpwalk -v 3 -u user -l AuthNoPriv -A password "$ip" "$3560mib") 
done < nmapres

or this:

Code:
while read ip
do
    snmpwalk -v 3 -u user -l AuthNoPriv -A password "$ip" "$3550mib" \
    || snmpwalk -v 3 -u user -l AuthNoPriv -A password "$ip" "$3560mib") 
done < nmapres

All three assume that their is a file called nmapres with one correctly
formated ip-address per line. It reads this ip-address into variable $ip,
runs you command with this ip-address and checks the exit status.
If the command failed, it runs your second command.

HTH Chris
 

6 More Discussions You Might Find Interesting

1. Ubuntu

how to connect to Cisco switch from Ubnutu

Hi, I installed Ubnutu on my old laptop which does have COMM port, I want to connect to Cisco switch, I have Cisco cable connected to laptop. On Windows, I usually bring up "Hyper Terminal" how do I do it here? Please advice. Thanks. (7 Replies)
Discussion started by: samnyc
7 Replies

2. Shell Programming and Scripting

perl Net::SNMP version getting info from cisco switch

I am having trouble working with SNMP module with perl. I am trying to get SNMP version of target system. I use following code to get it however it resturns error as "Argument "v6.0.1" isn't numeric in numeric lt (<) at ./chk_env_upd.pl line 447." Get load table my $resultat =... (1 Reply)
Discussion started by: dynamax
1 Replies

3. IP Networking

cisco switch + firewall configuration upgrade

Hi experts, I need to cope configuration from one switch/firewall to another switch/firewall. I have copied running configs. The question is do I have to clear the existing configuration on the dest. devices Or can I copy it(replace) directly without clearing previous config ? If... (2 Replies)
Discussion started by: hernand
2 Replies

4. Infrastructure Monitoring

Nagios 3.3.1 SNMP with Cisco Switch Fails

Hello all! I am running Nagios 3.3.1 and I am trying to get it to monitor the ports on my Cisco Catalyst 3524-XL-PWR Managed Switch. But I keep getting "(Return code of 127 is out of bounds - plugin may be missing)" I have installed and compiled the plugins and the snmp services on the Ubuntu... (0 Replies)
Discussion started by: RossIV
0 Replies

5. IP Networking

Free Cisco Catalyst Switch Lab

I've setup my Linux system, running Scientific Linux and ser2net, as a terminal server for my Cisco switches. Logon and have fun!! telnet 72.205.54.70 49001 telnet 72.205.54.70 49002 telnet 72.205.54.70 49003 For topology and updates go to http://labswitch.blogspot.com. Thanks! (3 Replies)
Discussion started by: yoda9999
3 Replies

6. IP Networking

Cisco 3750 Switch ASA VPN Routing

Hi,I want connect my ASA 5510 firewall to a 3750 switch with RIP routing. Unfortunately,I am having issues passing the VPN subnet through rip to the 3750.I don't understand how the routing table is populated on the ASA. Any suggestions? (0 Replies)
Discussion started by: Ayaerlee
0 Replies
ARPFETCH(8)						      System Manager's Manual						       ARPFETCH(8)

NAME
arpfetch - obtain ethernet/ip address pairings via snmp SYNOPSIS
arpfetch host cname DESCRIPTION
arpfetch gets pairings between ip addresses and the ethernet address of the corresponding network card. These pairings are retrieved from other network entities, like routers, by the SNMP protocol using snmpwalk(1). Mostly, this program is an agent that is used to get data for arpsnmp(8). This fetching of address mappings can be further automated by use of bihourly(8). Both command arguments must be present for proper operation. The host argument is the hostname of the network entity being queried and the cname argument is the SNMP community name of the network entity. The information is presented on stdout in a format compatible with arpsnmp(8) and arpwatch(8). Further information about SNMP can be found in snmpcmd(1) and variables(5). SEE ALSO
arpsnmp(8), arpwatch(8), bihourly(8), snmpwalk(1), snmpcmd(1), variables(5) BUGS
Please send bug reports to arpwatch@ee.lbl.gov. AUTHORS
Craig Leres of the Lawrence Berkeley National Laboratory Network Research Group, University of California, Berkeley, CA. The current version is available via anonymous ftp: ftp://ftp.ee.lbl.gov/arpwatch.tar.gz This manual page was contributed by Hugo Graumann. ARPFETCH(8)
All times are GMT -4. The time now is 07:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy