Cisco 2960-X running IOS version 15.2(2)E6
Host(server trying to reach the switch):
I want to save the learned MAC addresses from the switch periodically to maintain a "who was where and when" database of the client devices.
I know of the SNMP approach (where different MIBs are read and correlated) but due to reasons I would like not to discuss here I cannot use SNMP.
My solution is to save a public-ssh key on the switch and issue the following command:
ssh user@switch "show mac address-table" > outputfile.txt
Generally the command works and the output of the "sh mac add" will be redirected to the outputfile. BUT:
About 20% of the tries I end up with an 8kb (exactly 8kb) file as the output, the rest is truncated somehow, right in the middle of the output.
Does someone know why my files get truncated?
I forgot to mention that the ssh command is in a bash script that is run by cron every X minutes. To be exact 2 commands are now in the script for 2 different switches and the anomaly is not restricted to the second switch - both of them return sometimes 8k results.
If I alter the script to execute the 2 ssh commands in a loop and call it directly from my shell the problem seems to disappear... (Originally the script was called by cron) My conclusion is that it has something to do with cron.