ifconfig 下面的一些字段(errors, dropped, overruns)

本文通过分析一台频繁出现丢包报警的机器,深入探讨了网络丢包的各种原因及解决办法。通过对ethtool和ifconfig命令输出的解读,确定了问题出现在接收队列满导致的丢包,并给出了调整中断亲和性和监控网络流量的具体措施。
一台机器经常收到丢包的报警,先看看最底层的有没有问题: 
# ethtool  em2 | egrep 'Speed|Duplex' 
        Speed: 1000Mb/s 
        Duplex: Full

# ethtool  -S em2 | grep crc 
     rx_crc_errors: 0

Speed, Duplex, CRC 之类的都没问题,基本可以排除物理层面的干扰。 
通过 ifconfig 可以看到 overruns 字段在不停的增大: 
# for i in `seq 1 10`; do ifconfig em2 | grep RX | grep overruns; sleep 1; done

dropped 出现问题的倒是遇到过几次,overruns 的倒是第一次遇到,再看看下面这个: 
# ethtool  -S em2 | grep drop 
     dropped_smbus: 0 
     tx_dropped: 0 
     rx_queue_0_drops: 26649441 
     rx_queue_1_drops: 26096911 
     rx_queue_2_drops: 22712954 
     rx_queue_3_drops: 16581572 
     rx_queue_4_drops: 27349880 
     rx_queue_5_drops: 6178622 
     rx_queue_6_drops: 19882243 
     rx_queue_7_drops: 18802558

发现数值也在不停的增加。G 了一下,发现这些 errors, dropped, overruns 表示的含义还不大一样。根据这篇文档的解释: 
# ifconfig em2 
em2       Link encap:Ethernet  HWaddr AC:85:3D:A9:03:0D   
          inet addr:211.211.211.211  Bcast:211.211.211.255  Mask:255.255.255.0 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1 
          RX packets:17141208886 errors:0 dropped:0 overruns:164254181 frame:0 
          TX packets:14685534428 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:2619578349554 (2.3 TiB)  TX bytes:1479317006067 (1.3 TiB) 
          Memory:94b00000-94b20000

RX errors: 表示总的收包的错误数量,这包括 too-long-frames 错误,Ring Buffer 溢出错误,crc 校验错误,帧同步错误,fifo overruns 以及 missed pkg 等等。 
RX dropped: 表示数据包已经进入了 Ring Buffer,但是由于内存不够等系统原因,导致在拷贝到内存的过程中被丢弃。 
RX overruns: 表示了 fifo 的 overruns,这是由于 Ring Buffer(aka Driver Queue) 传输的 IO 大于 kernel 能够处理的 IO 导致的,而 Ring Buffer 则是指在发起 IRQ 请求之前的那块 buffer。很明显,overruns 的增大意味着数据包没到 Ring Buffer 就被网卡物理层给丢弃了,而 CPU 无法即使的处理中断是造成 Ring Buffer 满的原因之一,上面那台有问题的机器就是因为 interruprs 分布的不均匀(都压在 core0),没有做 affinity 而造成的丢包。 
RX frame: 表示 misaligned 的 frames。

对于 TX 的来说,出现上述 counter 增大的原因主要包括 aborted transmission, errors due to carrirer, fifo error, heartbeat erros 以及 windown error,而 collisions 则表示由于 CSMA/CD 造成的传输中断。

在梳理这些 error/drop/discard 的时候,由于涉及到不同的 NIC 型号,ethtool/netstat 或者是直接从 proc 里面获取到的数据所代表的意思还不完全一样,比如上面通过 ethtool 得到的「丢包」是通过 rx_queue_NUM_drops 这个字段表示的,而通过 netstat 看到的却是 RX-OVR 表示的,一个是 overruns 一个是 dropped,字面意思完全不同: 
# netstat -i | column  -t 
Kernel  Interface  table 
Iface   MTU        Met    RX-OK        RX-ERR  RX-DRP  RX-OVR     TX-OK        TX-ERR  TX-DRP  TX-OVR  Flg 
em2     1500       0      17159519100  0       0       164254181  14701510290  0       0       0       BMRU

不管是使用何种工具,最终的数据无外乎是从下面这两个文件获取到的:

/sys/class/net/em2/statistics/
/proc/net/dev
# cat /proc/net/dev | column  -t 
Inter-|            Receive      |        Transmit 
face               |bytes       packets  errs      drop       fifo  frame  compressed  multicast|bytes  packets      errs  drop  fifo  colls  carrier  compressed 
em2:2621515020998  17153788154  0        0         164254181  0     0      0           1480433225509    14696703883  0     0     0     0      0        0

对于上面出现的若干种问题,一方面是做好监控,另外一方面是出现问题的时候及时的想到各种的可能,无外乎那么几种。Google 过程中发现了 stackexchange 上还没人回答的问题,结合上面的,我顺便回答了一下,基本,遵循里面的四点,95% 以上的场景应该能轻松应对。

 

转载于:https://www.cnblogs.com/sysk/p/6065204.html

root@auto8676p164hyp:~# ifconfig br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.16.0.51 netmask 255.255.255.0 broadcast 0.0.0.0 inet6 fe80::c8ca:caff:fe23:301 prefixlen 64 scopeid 0x20<link> ether ca:ca:ca:23:03:01 txqueuelen 1000 (Ethernet) RX packets 680401 bytes 177718048 (169.4 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 490497 bytes 107762267 (102.7 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 br0.6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.16.6.51 netmask 255.255.255.0 broadcast 0.0.0.0 inet6 fe80::c8ca:caff:fe23:301 prefixlen 64 scopeid 0x20<link> ether ca:ca:ca:23:03:01 txqueuelen 1000 (Ethernet) RX packets 678859 bytes 177543434 (169.3 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 488164 bytes 107643306 (102.6 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 br0.13: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.16.13.51 netmask 255.255.255.0 broadcast 0.0.0.0 inet6 fe80::c8ca:caff:fe23:301 prefixlen 64 scopeid 0x20<link> ether ca:ca:ca:23:03:01 txqueuelen 1000 (Ethernet) RX packets 1207 bytes 111733 (109.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2317 bytes 117545 (114.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 dummy0: flags=195<UP,BROADCAST,RUNNING,NOARP> mtu 1500 inet6 fe80::9021:b3ff:fe8c:d59f prefixlen 64 scopeid 0x20<link> ether 92:21:b3:8c:d5:9f txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 10 bytes 700 (700.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet6 fe80::c8ca:caff:fe23:3ee prefixlen 64 scopeid 0x20<link> ether ca:ca:ca:23:03:ee txqueuelen 1000 (Ethernet) RX packets 681327 bytes 181246234 (172.8 MiB) RX errors 0 dropped 66698 overruns 0 frame 0 TX packets 454542 bytes 77436068 (73.8 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 25 base 0x3000 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 150373 bytes 21517936 (20.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 150373 bytes 21517936 (20.5 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 vmnet-ysau0: flags=67<UP,BROADCAST,RUNNING> mtu 1500 inet 172.16.16.1 netmask 255.255.255.0 broadcast 172.16.16.255 inet6 fe80::8cf8:68ff:febf:64bb prefixlen 64 scopeid 0x20<link> ether 8e:f8:68:bf:64:bb txqueuelen 1000 (Ethernet) RX packets 206 bytes 50670 (49.4 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 21 bytes 1758 (1.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 vmnet-ysau1: flags=67<UP,BROADCAST,RUNNING> mtu 1500 inet6 fe80::7485:a0ff:fe78:fd90 prefixlen 64 scopeid 0x20<link> ether 76:85:a0:78:fd:90 txqueuelen 1000 (Ethernet) RX packets 71210 bytes 25688501 (24.4 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 165767 bytes 44233436 (42.1 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 vmnet-ysau2: flags=67<UP,BROADCAST,RUNNING> mtu 1500 inet 172.16.117.2 netmask 255.255.255.0 broadcast 172.16.117.255 inet6 fe80::68fb:5dff:fef9:23ca prefixlen 64 scopeid 0x20<link> ether 6a:fb:5d:f9:23:ca txqueuelen 1000 (Ethernet) RX packets 8775 bytes 857174 (837.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 11820 bytes 2248417 (2.1 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 vmnet-ysau3: flags=67<UP,BROADCAST,RUNNING> mtu 1500 inet 172.16.50.1 netmask 255.255.255.0 broadcast 172.16.50.255 inet6 fe80::7c3b:3dff:fe46:a6ff prefixlen 64 scopeid 0x20<link> ether 7e:3b:3d:46:a6:ff txqueuelen 1000 (Ethernet) RX packets 126 bytes 28611 (27.9 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 16 bytes 1456 (1.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 vmnet-ysyu0: flags=67<UP,BROADCAST,RUNNING> mtu 1500 inet 172.16.17.1 netmask 255.255.255.0 broadcast 172.16.17.255 inet6 fe80::5065:3aff:fe72:b509 prefixlen 64 scopeid 0x20<link> ether 52:65:3a:72:b5:09 txqueuelen 1000 (Ethernet) RX packets 114 bytes 6872 (6.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 117 bytes 7158 (6.9 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 vmnet-ysyu1: flags=67<UP,BROADCAST,RUNNING> mtu 1500 inet6 fe80::a894:a0ff:fee7:8c7c prefixlen 64 scopeid 0x20<link> ether aa:94:a0:e7:8c:7c txqueuelen 1000 (Ethernet) RX packets 47799 bytes 8694820 (8.2 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 181022 bytes 50060181 (47.7 MiB) TX errors 0 dropped 20 overruns 0 carrier 0 collisions 0 vmnet-ysyu2: flags=67<UP,BROADCAST,RUNNING> mtu 1500 inet 172.16.34.1 netmask 255.255.255.0 broadcast 172.16.34.255 inet6 fe80::38c5:d2ff:fe55:a2ba prefixlen 64 scopeid 0x20<link> ether 3a:c5:d2:55:a2:ba txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 打印这些信息是什么,外界要使用SSH连接该节点,需要连接的IP是多少,密码怎样
最新发布
09-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值