Cisco WLC roaming debug + gawk + sed

Quite often I have to debug a wireless client roaming across lighweight Cisco APs to confirm it moves between APs as expected in the network design.

On the WLC the command is “debug client MAC”. The command shows all the events related to the specific client including:

Reassociation received from mobile on AP 00:23:ab:ba:YY:XX

that means client moved to the AP with radio MAC 00:23:ab:ba:YY:XX. Since I’ve named all the APs and and I’ve a map with all the positions, I’d like to see the names in the debug instead of MAC. Lastest WLC release (7.4.100) still shows only MAC so it’s time to fix that.

This site has 33 APs connected to this controller. The first step is to create file with a list containing AP NAME,MAC. See below hot to get the data:

We name this file “aplist.txt”.

We can use sed to replace the mac address with the name, with a command like this:

sed -e "s/00:14:f2:aa:bb:cc/G057/g"

Since copy/paste is not a proper way to do things, we ca use gawk to create all the sed lines we need.

With just a single awk line we read the aplist.txt file and write all the required sed commands:

awk 'BEGIN { FS="," } { print "s/" $2 "/" $1"/g"}' aplist.txt > sost.sed

The result is a file with one line with the correct sed command for each AP NAME/MAC couple.

So now the action begins. We connect via SSH to the controller and send all the output to /tmp/wlc.log:

ssh 10.99.99.99 | tee /tmp/wlc.log

My advice is to disable the ssh inactivity timeout on the WLC with:

config sessions timeout 0

Then enable the client debug with:

debug client 84:00:d2:aa:bb:cc

Now it’s time to manipulate the output. In another shell we exec:

tail -f /tmp/wlc.log | grep "association " | sed -f sost.sed

So now the log from WLC becomes:

Reassociation received from mobile on AP APxx

That’s quite easier to read, don’t you think?

Tech tip: if you see “association” in the logs it means the roaming didn’t worked and the client disconnected. If you see Reassociation the roaming worked fine.

I’m sure that after the effort to write those scripts the next WLC release will show both ap name and mac in the logs but I enjoyed the opportunity to learn more about sed and awk, two very powerful tools.

HTH

 
comments powered by Disqus