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.

3 comments:

  1. That's a great script but it misses one key point in campus networks: how do you know if a down port is actually unused?

    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.
    Replies
    1. You're totally correct... and it absolutely annoys me that I can't figure out how to get that information with a SHOW command ;))

      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.
  2. Automating TDR test and catching 0m could be a viable solution for down ports. That's what I do manually to re-check reports of "a wonderful network management tool".
Add comment
Sidebar