Getting DCA Channel Change counts with Python





I’ve been playing around with Python for over a year now – mostly writing scripts and programs to help me out with some tedious tasks at work. I had some prior scripts that leveraged both the piapi (for interacting with Cisco Prime) and netmiko (ssh access) python libraries and so I dug in and whipped up a quick program that given a .csv file of AP names, would output another .csv with the AP Name, Number of Channel Changes, and location in an easy to read format. The program does the following:

  1. Opens a ssh connection to the specified WLC
  2. Reads in the list of AP Names from the specified .csv file
  3. For each AP it:
    1. Runs the “show ap auto-rf 802.11a APNAME” command
    2. Grabs the channel change count as a string
    3. Connects to Prime and gets the location for the specified AP
    4. Writes the AP Name, Channel Change Count, and Location to a list
  4. Dumps the contents of the list to a .csv file

The ap-list.csv file just has the AP Names listed row by row in the first column – nothing else.

Disclaimer: This a very basic program with no error checking and probably some inefficient code – it does the job though 🙂

Output looks like this:


Once I had all my data on a nice spreadsheet I started to notice that we had single AP’s out in shacks in the middle of nowhere that were reporting channel changes every time DCA ran (at the 10 minute default). There was no reasonable explanation for that so I logged in to the WLC, checked the channel for one of those AP’s and then waited for DCA to run.

DCA runs, AP shows that the channel change count incremented by one, and guess what: NO ACTUAL CHANNEL CHANGE!

I verified the same behavior on several other AP’s. No actual channel changes but reporting as if there were. I reached out to the great wi-fi experts on the wi-fipros slack channel and the consensus was that is was probably a bug. Conveniently we had a code upgrade scheduled for that evening so I went ahead with the upgrade as planned and re-ran my program the next morning.

VOILA! I was no longer receiving false channel change counts on the controller. I have ran the program a few times over the last couple of weeks just to verify that the false channel changes have not returned and so far so good.

Conclusion: I love Python!

Leave a Reply
