Automation Solution: Create Switch Stack Reports
Have you ever wondered how many free ports you have on your stackable campus switches? I’m sure there must be a wonderful network management tool that creates that reports with a click of a button… but what if the tool your PHB purchased based on awesome PowerPoint and glitzy demo can’t do that?
Nadeem Lughmani decided to solve this challenge as a hands-on assignment in the Building Network Automation Solutions online course and created an Ansible playbook and a Python plugin that counts the total number of ports and number of free ports for each switch stack specified in the device inventory.
Wonder what else course attendees created in the past? Here’s a small sample.
Collecting the ifLastChange value helps to find down ports for a long time, meaning they are most likely to be actually down and free.
I've implemented it using SNMP as a CLI tool, it works to check one switch at a time:
https://github.com/routetonull/unpatchable
A better implementation with Ansible could scale the solution to the whole campus network.
As for scaling - if you don't care about performance, you could just modify your script to return JSON data structure and then slap Ansible on top of that to handle inventory etc.