It's better when it's simple

User Tools

Site Tools


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.

#Hack created by Michael Wheeler [] No warranty
#feel free to tidy up
server = "" #This is the TFP server address 
switchs = {"": "public"} #switch IP and snmp key
filename = {"": "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))
".": "integer 1",
".": "integer 4",
".": "integer 1",
".": "a " + server,
".": "integer 1",
for switch in switchs:
   oids["."] = "string "+ filename[switch]
   for oid in oids:
       os.system("snmpset -v 1 -c " + switchs[switch] + " " + switch + " " + oid + oidn + " " + oids[oid])
   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

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki