欧卡2中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

需要三步,才能开始

只需两步,慢速开始

查看: 8538|回复: 0
收起左侧

[互联网] 一个采集服务器所接交换机端口信息的脚本(支持CISCO和H3C的交换机)

[复制链接]
oppo 发表于 2015-2-12 12:41 | 显示全部楼层 |阅读模式
http://noops.me/?p=1184

[tex=code]function cisco(){
        net=1tcpdumpnnvinet -s 1500 -c 1 'ether[20:2] == 0x2000' > /tmp/tmp_get_port &
        sleep 60
        killall -9 tcpdump && return
        switch=`egrep "Device-ID|Device-ID" /tmp/tmp_get_port|sed "s/'//g"|awk '{print NF}'`          port=`egrep "Port-ID|Port-ID" /tmp/tmp_get_port|sed "s/'//g"|awk '{print $NF}'`          vlan=`grep "VLAN ID" /tmp/tmp_get_port|awk '{print $NF}'`          echoswitch > /tmp/tmp_get_port
        echo port>>/tmp/tmpgetportechovlan>> /tmp/tmp_get_port
}
function h3c(){
        net=1tcpdumpinet ether proto 0x88cc -A -s0 -t -c 1 -v > /tmp/tmp_get_port &
        sleep 60
        killall -9 tcpdump && cisco net && return          switch=`grep "System Name TLV" /tmp/tmp_get_port|sed -n '1p' |awk '{print $NF}'`          port=`grep "Subtype Interface Name" /tmp/tmp_get_port|sed -n '1p' |awk '{print $NF}'`          vlan=`grep "port vlan id" /tmp/tmp_get_port|sed -n '1p' |awk '{print $NF}'`          echoswitch > /tmp/tmp_get_port
        echo port>>/tmp/tmpgetportechovlan>> /tmp/tmp_get_port
}
echo ""> /tmp/tmp_net_list
netlist=`ifconfig|egrep -i "eth|em|p2p"|awk '{print 1}'|grep -v ":"`  for net in `echonetlist`;do
        h3c netswitch=sedn1p/tmp/tmpgetportport=sedn2p/tmp/tmpgetportvlan=sedn3p/tmp/tmpgetportechonet" "switch""port" "$vlan >> /tmp/tmp_net_list
done[/tex]
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

客服QQ936487697|联系我们|手机版|欧卡2中国 ( 湘ICP备11020288号-1 )

GMT+8, 2025-5-12 20:13 , Processed in 0.052146 second(s), 12 queries , Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表