Linux显示所有网络接口的协议级统计信息的摘要

时间:2020-01-09 10:40:25  来源:igfitidea点击:

问题描述:如何找到Linux下所有网络接口(如eth0,eth1)的协议级(IP,ICMP,TCPetc)统计信息摘要?

解决方法:
您可以使用标准的netstat命令来打印网络连接,路由表,接口统计信息,伪装连接和多播成员身份等。
-s选项的同一命令显示所有网络接口的协议级统计信息的摘要

# netstat -s | head -11

输出:

Ip:
    65213088 total packets received
    0 forwarded
    0 incoming packets discarded
    65190740 incoming packets delivered
    69694203 requests sent out
    7 outgoing packets dropped
    7 fragments dropped after timeout
    74 reassemblies required
    31 packets reassembled ok
    7 packet reassembles failed

您可以使用以下命令显示所有网络接口的表,包括发送(TX)和接收(RX)数据包:

# netstat -i

输出:

Kernel Interface table
Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500   0  2111089      0      0      0  3157931      0      0      0 BMRU
eth1       1500   0 24473949      0      0      0 27782130      0      0      0 BMRU
eth1:0     1500   0      - no statistics available -                            BMRU
eth1:1     1500   0      - no statistics available -                            BMRU
eth1:2     1500   0      - no statistics available -                            BMRU
eth1:3     1500   0      - no statistics available -                            BMRU
eth1:4     1500   0      - no statistics available -                            BMRU
lo        16436   0 38978328      0      0      0 38978328      0      0      0 LRU
vmnet8     1500   0        0      0      0      0        5      0      0      0 BMRU

您可以使用以下方式显示完整的报告:

# netstat -s

输出:

Ip:
    65220448 total packets received
    0 forwarded
    0 incoming packets discarded
    65198100 incoming packets delivered
    69701981 requests sent out
    7 outgoing packets dropped
    7 fragments dropped after timeout
    74 reassemblies required
    31 packets reassembled ok
    7 packet reassembles failed
Icmp:
    16896 ICMP messages received
    81 input ICMP message failed.
    ICMP input histogram:
        destination unreachable: 6304
        timeout in transit: 513
        redirects: 324
        echo requests: 9728
        echo replies: 2
    28314 ICMP messages sent
    0 ICMP messages failed
    ICMP output histogram:
        destination unreachable: 18586
        echo replies: 9728
Tcp:
    748691 active connections openings
    2147903 passive connection openings
    6902 failed connection attempts
    59598 connection resets received
    7 connections established
    65031695 segments received
    69547445 segments send out
    538462 segments retransmited
    493 bad segments received.
    70494 resets sent
Udp:
    131034 packets received
    18475 packets to unknown port received.
    0 packet receive errors
    135063 packets sent
TcpExt:
    37314 invalid SYN cookies received
    7157 resets received for embryonic SYN_RECV sockets
  20008248 packets directly queued to recvmsg prequeue.
    97028771 packets directly received from backlog
    224583254 packets directly received from prequeue
    23444229 packets header predicted
    27244 packets header predicted and directly queued to user
    TCPPureAcks: 12740601
    TCPHPAcks: 29096274
    TCPRenoRecovery: 85917
    TCPDSACKOldSent: 0
    TCPDSACKOfoSent: 0
    TCPDSACKRecv: 0
    TCPDSACKOfoRecv: 0
    TCPAbortOnSyn: 0
    TCPAbortOnData: 32369
    TCPAbortOnClose: 12938
    TCPAbortOnMemory: 0
    TCPAbortOnTimeout: 3357
    TCPAbortOnLinger: 0
    TCPAbortFailed: 0
    TCPMemoryPressures: 0