This repo is dedicated to housing some utilities I've built to explore intersections between Python-based network automation and PostgreSQL database interactions.
⚠️ Use these scripts at your own risk. These have not been thoroughly tested against any specific hardware/software releases. See LICENSE for details.
⚠️ Always test code in a safe test environment before using in production environments!
filename | purpose |
---|---|
.env.template | Use this as a template for filling out your .env file. The .env file is used for storing sensitive variables in your ENV_VARS. |
.gitignore | Tells git what files to ignore tracking on. |
LICENSE | Legal license for this codebase. |
README.md | The file you're reading right now! |
collect_eigrp.py | Script used for collecting information from EIGRP-speaking routers and storing metadata in PSQL database. |
logging.conf | Logging configuration for the Python logging library. Currently unused, will use in future. |
requirements.txt | Used by pip to automatically install all Python dependencies. |
sql_test.py | Simple python script to test out custom SQL queries. Handy to use while developing. |
This script collects live EIGRP information from Cisco routers. This is only tested to work on IOS routers, and there are likely many cases that it breaks.
From a high-level, the script:
- Creates two tables in your PSQL DB - "inventory" and "router_neighbors."
- These ultimately track a full inventory of discovered routers and a full table of each router's EIGRP neighborships.
- The script then SSHs to your "seed" router to discover its neighbors.
- The SSH script collects, using the netmiko library, several pieces of information about your router for inventorying.
- Finally, the script posts that data to the appropriate DBs, and then repeats the process on the seed_router's neighbors, then their neighbors, then their neighbors' neighbors.. ad nauseum.
- Once complete, both tables will be filled out with some helpful information on your EIGRP environment, assuming you can SSH to every device in the environment.
- You must have a dedicated PostgreSQL server built for this code to interact with.
- This code was developed using Python v3.12.5
-
Clone this repository to your machine.
-
Create a python virtual environment to contain all the code dependencies:
# Windows CMD cd local-path-to-cloned-repo python -m venv .
-
Active the virtual environment on your machine.
path/to/cloned/repo/Scripts/activate
-
Install all python dependencies:
pip install -r requirements.txt
-
Add all relevant variables to the .env file. Make sure to rename the .env.template file to simply '.env'.
⚠️ NEVER share access to this file! -
Edit the STATIC_VARS in collect_eigrp.py lines 227-232 to your values.
-
Run the python script
python collect_eigrp.py
-
Pray it works! The output from the script in your terminal should give you a clue on it's status. You can also query your PostgreSQL database for results.