【发布时间】:2013-12-26 13:31:12
【问题描述】:
是否可以在 Linux 中检查每个接口的统计数据,尤其是 ICMP 数据包? ifconfig 命令提供每个接口接收和发送数据包的统计信息:
-> /sbin/ifconfig eth1
eth1 Link encap:Ethernet HWaddr BC:30:5B:ED:DE:54
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:412327300 errors:0 dropped:0 overruns:0 frame:0
TX packets:765211747 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:327931865613 (312740.1 Mb) TX bytes:803392590272 (766174.8 Mb)
Memory:dcc00000-dcd00000
但我正在寻找的是每个接口的某些特定类型的数据包(如 ICMP)。
Linux 也在 /proc/net/snmp 中提供这些统计信息:
-> cat /proc/net/snmp
... log truncated ...
Icmp: InMsgs InErrors InDestUnreachs InTimeExcds InParmProbs InSrcQuenchs InRedirects InEchos InEchoReps InTimestamps InTimestampReps InAddrMasks InAddrMaskReps OutMsgs OutErrors OutDestUnreachs OutTimeExcds OutParmProbs OutSrcQuenchs OutRedirects OutEchos OutEchoReps OutTimestamps OutTimestampReps OutAddrMasks OutAddrMaskReps
Icmp: 29697 5 276 9 0 0 0 29409 3 0 0 0 0 29970 0 561 0 0 0 0 5 29404 0 0 0 0
IcmpMsg: InType0 InType3 InType8 InType11 OutType0 OutType3 OutType8
IcmpMsg: 3 276 29409 9 29404 561 5
... log truncated ...
或者使用 netstat -s 命令进行更漂亮的打印(当然,-s 代表统计信息):
-> netstat -s
... log truncated ...
Icmp:
29697 ICMP messages received
5 input ICMP message failed.
ICMP input histogram:
destination unreachable: 276
timeout in transit: 9
echo requests: 29409
echo replies: 3
29970 ICMP messages sent
0 ICMP messages failed
ICMP output histogram:
destination unreachable: 561
echo request: 5
echo replies: 29404
IcmpMsg:
InType0: 3
InType3: 276
InType8: 29409
InType11: 9
OutType0: 29404
OutType3: 561
OutType8: 5
... log truncated ...
所以,问题是。有什么方法可以获取某些特定接口的 ICMP 统计信息,而不是 Linux 中整个系统的全局 ICMP 统计信息?
【问题讨论】:
标签: linux interface statistics icmp packets