Some perl scripts for managing IOS Ciscos

These scripts need the net-snmp utilities from sourceforge.
Also a perl version is needed. I run it with Perl 5.8.1, which you can get from
ActiveState.
You can get the mentioned MIB files from
ftp://ftp.cisco.com/pub/mibs/v2.
For the getconf.pl script you'll also need a TFTP server to write the configs to. A free one for windows can be downloaded from 3COM.
I have tested them successfully on Linux and Windows XP.

getCdpNeighbours.pl

# Uses sourceforge net-snmp utilities and the CISCO-CDP-MIB.
# 1) Install net-snmp from http://net-snmp.sourceforge.net.
# 2) Download these mibs from ftp://ftp.cisco.com/pub/mibs/v2
#      CISCO-SMI  	 
#      SNMP-FRAMEWORK-MIB 		
#      RMON-MIB 		
#      CISCO-TC 		
#      CISCO-VTP-MIB 	
#      RFC1155-SMI 	
#      RFC-1212 	  	
#      SNMPv2-TC-v1 	
#      CISCO-CDP-MIB
# 3) Copy these MIBS to /usr/share/snmp/mibs or c:\usr\share\snmp\mibs, 
#    depending on where you installed the net-snmp utilities
# 4) In /usr/etc/snmp/snmp.conf, add the lines:
#    mibs +CISCO-CDP-MIB
#
#    This will allow textual OID's instead of numeric OID's.
#
# 5) Add the net-snmp bin directory to the PATH environment variable,
#    so that the script can find the executable.
#
# Example: Getting Cisco neighbour devices for IOS switch 10.170.41.5
#          'cisco' is the configured SNMP read community string.
#
D:\Dev\perl\ciscoworks>perl getCdpNeighbours.pl 10.170.41.5 cisco
10.170.41.62:Customer_Demo_:cisco WS-C3550-24
10.170.41.6:FastEthSwitch:cisco WS-C2924M-XL
10.170.41.30:Core:FE511
10.170.41.31:core:FE511
10.170.41.70:edge:FE511
10.170.41.65:Switch:Cisco WS-C3550-24


Perl script file:getCdpNeighbours.pl

getconf.pl

# This script uses SNMP to download the config file from a Cisco device to a 
# TFTP server.
#
# For background information, check out this cisco tech note.
#
# Uses sourceforge net-snmp utilities and the CISCO-CONFIG-COPY-MIB and CISCO-FLASH-MIB
# Copy these MIBS and also CISCO-SMI-V1SMI, SNMPv2-TC-V1SMI.my to /usr/share/snmp/mibs.
#
# In /usr/etc/snmp/snmp.conf, add the lines:
#    mibs +CISCO-CONFIG-COPY-MIB
#    mibs +CISCO-FLASH-MIB
#
# This will allow textual OID's instead of numeric OID's.
#
# Example: Sending config of IOS switch 10.170.41.5 to TFTP server 10.170.22.102.
#          'private' is the configured write community string on the switch.
#
D:\Dev\perl\ciscoworks>perl getconf.pl 10.170.41.5 private 10.170.22.102
Sending snmp trap: ok
Checking status: Success!
Resetting ccCopyEntry:ok
  
Perl script file: getconf.pl.