11-27-2008
using if to identify proper mib for use with a cisco switch
Happy ThanksGiving guys,
I'm working on a script that will use nmap to enumerate a network for active cisco switches. Once the list is complete, we use sed to clean up the file (called nmapres) so it is only a list of IP addresses. Next I want to use a while statement to go down that list of IPs and snmpwalk each switch to retreive that switches serial number and record it to a mysql db. The intent is to have a click option on a web site that will php shellexec this script and print out a list of active serial numbers on a network. Here is what I have so far and it is taking place on Fedora 9...
#!/bin/bash
/bin/touch error
/bin/touch log
# obtain a list of active devices
nmap -sP 10.0.0.0/24 > nmapres
# Clean nmapres up to just a list of IPs
sed -i 's/Starting.*//g' nmapres
sed -i 's/Host //g' nmapres
sed -i 's/ appears.*//g' nmapres
sed -i 's/Nmap.*//g' nmapres
sed -i /^$/d nmapres
# Identify some variables
line=1
num= 'wc -l < nmapres'
3550mib=mib-2.47.1.1.1.1.11.1
3560mib=mib-2.47.1.1.1.1.11.1001
# the real work
while [ "$line" -le "$num" ]
do
# Extract line x from file of ip addresses
ip=`sed -n "$line"p nmapres`
if
fi
# Used to increment loop variable
line=`expr "$line" + 1`
done
Between the if and fi I would like to snmpwalk each IP address and check if the switch prefers 3550mib or 3560mib. I know that if I snmpwalk a switch and it doesn't like the mib I query for I get this (SNMPv2-SMI::mib-2.47.1.1.1.1.11.1 = No Such Instance currently exists at this OID) but if the switch does like the requested mib the output is (SNMPv2-SMI::mib-2.47.1.1.1.1.11.1001 = STRING: "serial number"). Do you guys know how I could do this?
Thanks.
6 More Discussions You Might Find Interesting
1. Ubuntu
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
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
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
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
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
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
LEARN ABOUT CENTOS
snmpwalk
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.7.2 28 May 2007 SNMPWALK(1)