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
SNMPWALK(1)							     Net-SNMP							       SNMPWALK(1)

NAME
snmpwalk - retrieve a subtree of management values using SNMP GETNEXT requests SYNOPSIS
snmpwalk [APPLICATION OPTIONS] [COMMON OPTIONS] AGENT [OID] DESCRIPTION
snmpwalk is an SNMP application that uses SNMP GETNEXT requests to query a network entity for a tree of information. An object identifier (OID) may be given on the command line. This OID specifies which portion of the object identifier space will be searched using GETNEXT requests. All variables in the subtree below the given OID are queried and their values presented to the user. Each variable name is given in the format specified in variables(5). If no OID argument is present, snmpwalk will search the subtree rooted at SNMPv2-SMI::mib-2 (including any MIB object values from other MIB modules, that are defined as lying within this subtree). If the network entity has an error processing the request packet, an error packet will be returned and a message will be shown, helping to pinpoint why the request was malformed. If the tree search causes attempts to search beyond the end of the MIB, the message "End of MIB" will be displayed. OPTIONS
-Cc Do not check whether the returned OIDs are increasing. Some agents (LaserJets are an example) return OIDs out of order, but can complete the walk anyway. Other agents return OIDs that are out of order and can cause snmpwalk to loop indefinitely. By default, snmpwalk tries to detect this behavior and warns you when it hits an agent acting illegally. Use -Cc to turn off this check. -CE {OID} End the walk at the specified OID, rather than a simple subtree. This can be used to walk a partial subtree, selected columns of a table, or even two or more tables within a single command. -Ci Include the given OID in the search range. Normally snmpwalk uses GETNEXT requests starting with the OID you specified and returns all results in the MIB subtree rooted at that OID. Sometimes, you may wish to include the OID specified on the command line in the printed results if it is a valid OID in the tree itself. This option lets you do this explicitly. -CI In fact, the given OID will be retrieved automatically if the main subtree walk returns no useable values. This allows a walk of a single instance to behave as generally expected, and return the specified instance value. This option turns off this final GET request, so a walk of a single instance will return nothing. -Cp Upon completion of the walk, print the number of variables found. -Ct Upon completion of the walk, print the total wall-clock time it took to collect the data (in seconds). Note that the timer is started just before the beginning of the data request series and stopped just after it finishes. Most importantly, this means that it does not include snmp library initialization, shutdown, argument processing, and any other overhead. In addition to these options, snmpwalk takes the common options described in the snmpcmd(1) manual page. EXAMPLES
Note that snmpbulkget REQUIRES an argument specifying the agent to query and at most one OID argument, as described there. The command: snmpwalk -Os -c public -v 1 zeus system will retrieve all of the variables under system: sysDescr.0 = STRING: "SunOS zeus.net.cmu.edu 4.1.3_U1 1 sun4m" sysObjectID.0 = OID: enterprises.hp.nm.hpsystem.10.1.1 sysUpTime.0 = Timeticks: (155274552) 17 days, 23:19:05 sysContact.0 = STRING: "" sysName.0 = STRING: "zeus.net.cmu.edu" sysLocation.0 = STRING: "" sysServices.0 = INTEGER: 72 (plus the contents of the sysORTable). The command: snmpwalk -Os -c public -v 1 -CE sysORTable zeus system will retrieve the scalar values, but omit the sysORTable. SEE ALSO
snmpcmd(1), snmpbulkwalk(1), variables(5). V5.6.2.1 28 May 2007 SNMPWALK(1)
All times are GMT -4. The time now is 03:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy