Getting DCA Channel Change counts with Python

First blog post (and it’s long) so let’s just get down to brass tacks…

I recently had a minor panic attack when I was looking at all the fancy stats that show ap auto-rf 802.11a “ap name” gives you on a Cisco WLC. All 3 of my controllers were showing hundreds, if not thousands, of channel changes for a vast majority of the associated APs. My first thought was that there was something in my RF environment causing Dynamic Channel Assignment (DCA) to constantly be changing the channel plan. From what I could recall though, Cisco had designed DCA to keep cascading channel changes from rippling though the entire wireless environment. The numbers were indicating otherwise though.

A small sampling of random AP’s across sites large and small was turning up a large number of high channel change counts regardless of site. I decided that I wanted to see what my channel changes looked like for each AP. We have almost 500 AP’s so running the above command on each AP wasn’t the best use of time plus I was having to go into Cisco Prime to look up each AP’s physical location. So with the problem at hand I decided it was…

…PYTHON TIME!!

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:


SO…

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!

One Reply to “Getting DCA Channel Change counts with Python”

Leave a Reply

Your email address will not be published. Required fields are marked *