Skip to content
Netmiko-based scripts to assist the Network Administrators and Engineers of the world!
Branch: master
Clone or download
admiralspark Merge pull request #48 from admiralspark/errorhandling
Added error-handling for network connectivity/not accessible switches
Latest commit fdfbf51 Dec 27, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example_Scripts Changed Fortigate blacklist script to have better comments Mar 9, 2018
.gitignore Updating gitignore Feb 21, 2018
LICENSE Initial commit Oct 15, 2016 Added more links in Jan 30, 2017 a few minor changes Jul 11, 2018 missed a file Nov 27, 2017 fixing formatting... Dec 5, 2016 initial work to extrapolate into multithreaded functions Nov 27, 2017 Added error-handling for network connectivity/not accessible switches Dec 26, 2018


Multithreaded parallel network command execution, simplified, for network engineers of the world!


Table of Contents


For everything:

pip install netmiko docopt getpass


Clone the repo, and run the scripts using Python 3. This is NOT a library or module, it is meant to be templates and examples that you can use, copy, and make better.


Create your 'customer' file and 'credentials' file based on

python -h

This script is the master controller script. It will make the necessary commands to run whatever is needed against whatever is needed.

Usage: -h | --help (--info COMMAND | --config CONFIGFILE) (--csv FILENAME | --db QUERYNAME | --ip IPADDR) [-c CREDFILE] [--debug]

    -h, --help          Shows this menu.
    -d, --debug         Print debug information. This is the most verbose
    --info COMMAND   This will run regular show commands
    --config CONFIGFILE This will run configuration commands
    --csv FILENAME      Input file if using CSV [default: test.csv]
    --db QUERYNAME      SQL field: 'groupname' [default: test]
    --ip IPADDR         Single IP address of test switch
    -c CREDFILE         Crednetials file [default: credentials.csv]


To run write mem on every host in your csv file switches.csv (assuming you only have one credentials.csv):

python --info "wr mem" --csv switches.csv

To make a config change with many lines, such as changing a local account, you'd make a text file with the lines to change it which will then be run against the hosts. For example, lets make a changeuser.txt:

conf t revert time 5
username secretbackdoor privilege 15 password Thiscantbereal!

--config runs in the context of config mode, which is why I use an exit above.

Then you'd run it like so: python --config changeuser.txt --csv switches.csv

This command supports all of the netmiko classes of devices, but I designed it to be used with Cisco gear since that's what most of us run. You just need to specify a different device object in your switches.csv file to work with new stuff.

Final example, lets say you have a rogue sysadmin at one branch who refuses to use newer credentials/radius/whatever. So you have a different nonstandard set of creds and routers.

python --info "configure confirm" --csv crappyrouters.csv -c crappycreds.csv


This is multithreaded and I haven't added error handling. I force all of my changes to use config revision (the 'conf t revert time 5' above) as a workaround until I have good error handling in place. It's laziness and a lack of time, it would be decently easy to implement.

The multiprocess code I wrote is messy because of context issues. I plan on making that part into a library later on, but something something time and laziness.

The default number of simultaneous executions is 8, I have run this successfully at 50x simultaneous on a network of 400+ devices but keep in mind that they will return output at a rate of 50x, and it spits it out to STDOUT, so you might want to just leave it.

I will add support for --db and --ip later on, probably --db first because I want this to dive into the rest of my open-source stack I'm slowly writing about on so that this all ties in beautifully.

The Example_Scripts folder

This is old code and alternative projects. It is useful reference material so I'm leaving it up, but it will not be updated.


All patches welcome! Please read for furthers details...whenever I make it. For now, submit PR's and we'll chat about them.


GNU GPL Version 3 - see the LICENSE file for details

You can’t perform that action at this time.