大网数据广告活动
服务器运维问答

Cisco 2960-X ssh output truncated

· 52CE 我爱测

Target(switch): Cisco 2960-X running IOS version 15.2(2)E6 Host(server trying to reach the switch): FreeBSD 11.0-RELEASE I want to save the learned MAC addresses from the switch periodically to maintain a "who was where and when"…

问题原文

原帖链接 · TeBe · CC BY-SA 3.0

Target(switch):
Cisco 2960-X running IOS version 15.2(2)E6

Host(server trying to reach the switch):
FreeBSD 11.0-RELEASE

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?

UPDATE1:
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.

UPDATE2:
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.

已采纳解答

原帖链接 · Stefan · CC BY-SA 3.0

I had exactly the same issue, after about 64.000 byte the output got cut - but only when running it via cron. After troubleshooting I found the following solution

ssh user@switch "show mac address-table"

replace by

ssh user@switch < echo "show mac address-table"

Please dont ask my why the solution works....

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-06-16)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。