tips:cisco_config_archive
Cisco Config Archive
A hacked up scripted to use snmpset to get a Cisco device to tftp the config to a server, then imports it into DokuWiki. One day I might clean this up. Mainly just a prototype.
#!/usr/local/bin/python #Hack created by Michael Wheeler [mwheeler.org] No warranty #feel free to tidy up server = "172.27.2.1" #This is the TFP server address switchs = {"172.27.1.3": "public"} #switch IP and snmp key filename = {"172.27.1.3": "sayre_c2940_1"} #snmp filename to save, depending on your tftpd this file will have to be created first #code will most likely need to be changed below. import os import random import time oidn = str(int(random.random()*1000)) oids={ ".1.3.6.1.4.1.9.9.96.1.1.1.1.2.": "integer 1", ".1.3.6.1.4.1.9.9.96.1.1.1.1.3.": "integer 4", ".1.3.6.1.4.1.9.9.96.1.1.1.1.4.": "integer 1", ".1.3.6.1.4.1.9.9.96.1.1.1.1.5.": "a " + server, ".1.3.6.1.4.1.9.9.96.1.1.1.1.14.": "integer 1", } for switch in switchs: oids[".1.3.6.1.4.1.9.9.96.1.1.1.1.6."] = "string "+ filename[switch] for oid in oids: os.system("snmpset -v 1 -c " + switchs[switch] + " " + switch + " " + oid + oidn + " " + oids[oid]) time.sleep(10) os.system("(echo \"<code>\"; cat /tftpboot/"+filename[switch]+" | grep -v password | grep -v secret ; echo \"</code>\";) > /tmp/"+filename[switch]) #you can prob pipe this without saving a temp file.... but oh well. This script doesn't tidy up either. greps passwords out from tfpt root and saves it into tmp os.system("/usr/local/www/dokuwiki/bin/dwpage.php -m \"Auto from TFTP\" commit /tmp/"+filename[switch]+" configs:backup:"+filename[switch]) #path to dwpage, and namespace needs to be edited here.
tips/cisco_config_archive.txt · Last modified: 2010-04-07 04:14 by 24.22.140.79