特別是可以檢查Linux中每個接口的ICMP數據包的統計信息嗎? 使用ifconfig命令它提供了每個接口的統計數據接收和發送的數據包:是否可以統計Linux中每個接口發送/接收的ICMP數據包的數量?
-> /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 /淨/ 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統計信息,而不是整個系統的全局ICMP統計信息?
感謝您的回答,實際上我也仔細檢查了實施本身(更新了我的問題),看起來您的答案完全正確。 –
實際上,您指出的統計信息可以在/ sys/class/net//statistics中檢索。 –