+ -
当前位置:首页 → 问答吧 → 读取 /proc/net/dev 接口流量异常

读取 /proc/net/dev 接口流量异常

时间:2010-12-01

来源:互联网

64 位 Linux 操作系统,内核是 2.6.24.4.
Intel 82571EB/82574L 各两个网卡,共四个网卡。
启用  bond0 接口,绑定的是 eth1~eth3 三个物理接口。

第一次执行 ifconfig 和读取 /proc/net/dev 的结果:


QUOTE:
bond0     Link encap:Ethernet  HWaddr 00:1B:21:76:B7:0F
          RX bytes:1061540721 (1012.3 MiB)  TX bytes:25037722381116 (22.7 TiB)

Inter-|   Receive                                                |  Transmit
face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
  eth0:1535184500520 10424315082    0    0    0     0          0         0  1590336   37860    0    0    0     0       0          0
  eth1:384620021 2815402    0    0    0     0          0         0 8346411863363 5920195527    0    0    0     0       0          0
  eth2:220620893 1679889    0    0    0     0          0         0 8345522350129 5919726062    0    0    0     0       0          0
  eth3:456299807 2080486    0    0    0     0          0         0 8345788254436 5919817046    0    0    0     0       0          0
bond0:1061540721 6575777    0    0    0     0          0         0 25037722467928 17759738635    0    0    0     0       0          0



可见 bond0 的流入流出流量的统计均是 eth1~eth3 的综合。

间隔 4 s, 再次执行 ifconfig 和读取 /proc/net/dev 的结果:


QUOTE:
bond0     Link encap:Ethernet  HWaddr 00:1B:21:76:B7:0F
          RX bytes:1061544081 (1012.3 MiB)  TX bytes:25038184672034 (22.7 TiB)

Inter-|   Receive                                                |  Transmit
face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
  eth0:1535208161709 10424508953    0    0    0     0          0         0  1590336   37860    0    0    0     0       0          0
  eth1:384623321 2815457    0    0    0     0          0         0 8346565868923 5920299686    0    0    0     0       0          0
  eth2:220620893 1679889    0    0    0     0          0         0 8345676594504 5919830373    0    0    0     0       0          0
  eth3:456299867 2080487    0    0    0     0          0         0 8345942317509 5919921207    0    0    0     0       0          0
bond0:2123088162 13151666    0    0    0     0          0         0 41730692967368 29600272159    0    0    0     0       0          0



发现 bond0 统计流入流量基本上是倍增,流出流量也变化特别大。不符合 eth1~eth3 的相加结果。

也就是连续采集的两次实际流量没有出现较大波动,这个也可以从 eth1~eth3 的统计结果看出来,但是 第二次得到的 /proc/net/dev 中 bond0 的结果却是异常的,并且 ifconfig 得到的 bond0 的流量又是正常的。

大家帮忙分析一下。

作者: Godbach   发布时间: 2010-12-01

我这边没有这个问题。
版主看下/sys/class/net/bond0/statistics/中的值看下正常么?

作者: sky_peter   发布时间: 2010-12-01

谢谢 LS 的。
这个问题不是出现很频繁,偶尔才能抓到一次异常。

作者: Godbach   发布时间: 2010-12-01

奇怪的是 ,ifconfig 的结果应该也是从 /proc/net/dev 读出来的。
但是第二次的 ifconfig bond0 的结果没问题,但是  /proc/net/dev 有问题

作者: Godbach   发布时间: 2010-12-01