2021-05-12 14:32:11
Linux網路統計工具/命令
2020-06-16 17:59:09
我在Linux(基於CentOS 或者 Debian 的發行版)中該如何檢視當前網路埠吞吐量的統計資訊?在Linux作業系統中如何檢視當前核心snmp計數器以及網路埠的統計資訊?
你可以使用以下任何一個命令:
nstat 命令 : 網路統計工具
鍵入以下命令:
# nstat
輸出樣例:
#kernel
IpInReceives1332430.0
IpInDelivers1332430.0
IpOutRequests929040.0
IcmpOutErrors970.0
IcmpOutTimeExcds970.0
IcmpMsgOutType3970.0
TcpActiveOpens5380.0
TcpEstabResets560.0
TcpInSegs1298370.0
TcpOutSegs897200.0
TcpRetransSegs420.0
TcpOutRsts7040.0
UdpInDatagrams32550.0
UdpNoPorts970.0
UdpOutDatagrams32700.0
Ip6OutNoRoutes2060.0
TcpExtTW1410.0
TcpExtDelayedACKs5080.0
TcpExtDelayedACKLocked10.0
TcpExtDelayedACKLost420.0
TcpExtTCPHPHits1176590.0
TcpExtTCPPureAcks21580.0
TcpExtTCPHPAcks6050.0
TcpExtTCPSackRecovery10.0
TcpExtTCPLossUndo160.0
TcpExtTCPSackFailures40.0
TcpExtTCPFastRetrans10.0
TcpExtTCPSlowStartRetrans30.0
TcpExtTCPTimeouts330.0
TcpExtTCPDSACKOldSent400.0
TcpExtTCPDSACKRecv50.0
TcpExtTCPAbortOnData1200.0
TcpExtTCPAbortOnClose550.0
TcpExtTCPSackShiftFallback90.0
IpExtInOctets1801316820.0
IpExtOutOctets72891060.0
ss 命令 : 查詢通訊端工具
要檢視統計彙總, 輸入:
# ss -s
輸出樣例:
Total:786(kernel 804)
TCP:65(estab 40, closed 7, orphaned 0, synrecv 0, timewait 6/0), ports 56
TransportTotal IP IPv6
*804--
RAW 110
UDP 1293
TCP 58526
INET 71629
FRAG 000
檢視ss 命令教學 獲取更多資訊。
netstat 命令 : 不錯的顯示通訊端資訊的舊工具
檢視所有網路埠以及匯總資訊表,輸入:
# netstat -i
輸出樣例:
KernelInterface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 15000941022000688165000 BMRU
lo 16436093040009304000 LRU
ppp0 1496037840004177000 MOPRU
檢視每個協定的匯總統計資訊,輸入:
# netstat -s
輸出樣例:
Ip:
1092065 total packets received
0 forwarded
0 incoming packets discarded
1091681 incoming packets delivered
798913 requests sent out
895 dropped because of missing route
759 reassemblies required
375 packets reassembled ok
Icmp:
17 ICMP messages received
0 input ICMP message failed.
ICMP input histogram:
timeout in transit:8
echo replies:9
1747 ICMP messages sent
0 ICMP messages failed
ICMP output histogram:
destination unreachable:1730
echo request:17
IcmpMsg:
InType0:9
InType11:8
OutType3:1730
OutType8:17
Tcp:
4822 active connections openings
1129 passive connection openings
457 failed connection attempts
165 connection resets received
7 connections established
1062519 segments received
771394 segments send out
7158 segments retransmited
6 bad segments received.
2578 resets sent
Udp:
20846 packets received
1730 packets to unknown port received.
0 packet receive errors
19242 packets sent
UdpLite:
TcpExt:
71 invalid SYN cookies received
8 resets received for embryonic SYN_RECV sockets
142 packets pruned from receive queue because of socket buffer overrun
2109 TCP sockets finished time wait in fast timer
84 packets rejects in established connections because of timestamp
19454 delayed acks sent
6 delayed acks further delayed because of locked socket
Quick ack mode was activated 7306 times
1 packets directly queued to recvmsg prequeue.
1 bytes directly received in process context from prequeue
823921 packet headers predicted
24412 acknowledgments not containing data payload received
10150 predicted acknowledgments
242 times recovered from packet loss by selective acknowledgements
33 congestion windows recovered without slow start by DSACK
335 congestion windows recovered without slow start after partial ack
336 TCP data loss events
TCPLostRetransmit:35
1 timeouts after reno fast retransmit
156 timeouts after SACK recovery
116 timeouts in loss state
461 fast retransmits
5 forward retransmits
608 retransmits in slow start
2073 other TCP timeouts
62 SACK retransmits failed
43074 packets collapsed in receive queue due to low socket buffer
8499DSACKs sent for old packets
101DSACKs sent forout of order packets
308DSACKs received
9DSACKsforout of order packets received
427 connections reset due to unexpected data
122 connections reset due to early user close
28 connections aborted due to timeout
TCPDSACKIgnoredOld:3
TCPDSACKIgnoredNoUndo:60
TCPSpuriousRTOs:4
TCPSackShifted:282
TCPSackMerged:740
TCPSackShiftFallback:1017
IpExt:
InMcastPkts:47
OutMcastPkts:51
InBcastPkts:1
InOctets:1341508973
OutOctets:72525352
InMcastOctets:8649
OutMcastOctets:7519
InBcastOctets:328
檢視 netstat 命令教學 獲取更多資訊 http://www.linuxidc.com/Linux/2014-12/110150.htm。
ip / ifconfig 命令 : 設定或者顯示網路埠資訊
鍵入以下命令:
# ifconfig
或者
# /sbin/ifconfig
或者
# ifconfig eth0
eth0 Link encap:EthernetHWaddr b8:ac:6f:65:31:e5
inet addr:192.168.1.5Bcast:192.168.1.255Mask:255.255.255.0
inet6 addr: fe80::baac:6fff:fe65:31e5/64Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500Metric:1
RX packets:966334 errors:0 dropped:0 overruns:0 frame:0
TX packets:703297 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1186255648(1.1GiB) TX bytes:73968238(70.5MiB)
Interrupt:17
lo Link encap:LocalLoopback
inet addr:127.0.0.1Mask:255.0.0.0
inet6 addr:::1/128Scope:Host
UP LOOPBACK RUNNING MTU:16436Metric:1
RX packets:9666 errors:0 dropped:0 overruns:0 frame:0
TX packets:9666 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1399578(1.3MiB) TX bytes:1399578(1.3MiB)
ppp0 Link encap:Point-to-PointProtocol
inet addr:10.1.11.70 P-t-P:10.0.31.18Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1496Metric:1
RX packets:3784 errors:0 dropped:0 overruns:0 frame:0
TX packets:4177 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:2400265(2.2MiB) TX bytes:275983(269.5KiB)
顯示網路埠統計資訊,輸入:
# ip -s link
輸出樣例:
1: lo: mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
RX: bytes packets errors dropped overrun mcast
144418799600000
TX: bytes packets errors dropped carrier collsns
144418799600000
2: eth0: mtu 1500 qdisc mq state UP qlen 1000
link/ether b8:ac:6f:65:31:e5 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
122195648399150100024
TX: bytes packets errors dropped carrier collsns
756239377202720000
3: wlan0: mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 00:21:6a:ca:9b:10 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
000000
TX: bytes packets errors dropped carrier collsns
000000
4: pan0: mtu 1500 qdisc noop state DOWN
link/ether 4a:c7:5f:0e:8e:d8 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
000000
TX: bytes packets errors dropped carrier collsns
000000
8: ppp0: mtu 1496 qdisc pfifo_fast state UNKNOWN qlen 3
link/ppp
RX: bytes packets errors dropped overrun mcast
241988138480000
TX: bytes packets errors dropped carrier collsns
28415142870000
sar 命令: 顯示網路統計資訊
輸入以下命令 (你需要 通過sysstat包安裝並啟用sar):
sar -n DEV
Linux2.6.32-220.2.1.el6.x86_64 (www.cyberciti.biz)Tuesday13March2012 _x86_64_ (2 CPU)
12:00:01 CDT IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
12:10:01 CDT lo 0.000.000.000.000.000.000.00
12:10:01 CDT eth0 127.13121.3295.4518.340.000.000.00
12:10:01 CDT eth1 98.48110.6216.7296.330.000.000.00
12:20:01 CDT lo 0.000.000.000.000.000.000.00
12:20:01 CDT eth0 139.95133.41106.3019.950.000.000.00
12:20:01 CDT eth1 110.65121.8518.14107.130.000.000.00
12:30:01 CDT lo 0.000.000.000.000.000.000.00
12:30:01 CDT eth0 147.85132.49115.7820.450.000.000.00
12:30:01 CDT eth1 111.88127.3918.61117.650.000.000.00
12:40:01 CDT lo 0.000.000.000.000.000.000.00
12:40:01 CDT eth0 136.75124.64105.2419.480.000.000.00
12:40:01 CDT eth1 101.65115.3217.58104.500.000.000.00
12:50:01 CDT lo 0.000.000.000.000.000.000.00
12:50:01 CDT eth0 131.45125.6996.4919.580.000.000.00
12:50:01 CDT eth1 101.41111.3117.5496.780.000.000.00
01:00:01 CDT lo 0.000.000.000.000.000.000.00
01:00:01 CDT eth0 140.30133.27102.1720.750.000.000.00
01:00:01 CDT eth1 106.90119.5118.53103.090.000.000.00
01:10:01 CDT lo 0.000.000.000.000.000.000.00
01:10:01 CDT eth0 152.03127.74125.5619.850.000.000.00
01:10:01 CDT eth1 115.60134.5718.73126.960.000.000.00
01:20:01 CDT lo 0.000.000.000.000.000.000.00
01:20:01 CDT eth0 138.55130.55103.0320.200.000.000.00
....
..
....
..
.
01:00:01 CDT eth1 156.82169.4828.83138.490.000.000.00
01:10:01 CDT lo 0.000.000.000.000.000.000.00
01:10:01 CDT eth0 215.19194.82163.1130.990.000.000.00
01:10:01 CDT eth1 162.49183.7928.36163.700.000.000.00
01:20:01 CDT lo 0.000.000.000.000.000.000.00
01:20:01 CDT eth0 200.20192.23140.6430.930.000.000.00
01:20:01 CDT eth1 153.60166.9627.32140.260.000.000.00
01:30:01 CDT lo 0.000.000.000.000.000.000.00
01:30:01 CDT eth0 111.98103.5879.1216.520.000.000.48
01:30:01 CDT eth1 87.5095.5814.7479.350.000.000.00
Average: IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
Average: lo 0.000.000.000.000.000.000.00
Average: eth0 211.21196.20156.1831.200.000.000.01
Average: eth1 159.10174.5228.00149.950.000.000.00
或者輸入以下命令:
# sar -n DEV 1 3
輸出樣例:
Linux2.6.32-220.2.1.el6.x86_64 (www.cyberciti.biz)Tuesday13March2012 _x86_64_ (2 CPU)
01:44:03 CDT IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
01:44:04 CDT lo 0.000.000.000.000.000.000.00
01:44:04 CDT eth0 161.70154.26105.2026.630.000.000.00
01:44:04 CDT eth1 145.74142.5525.11144.940.000.000.00
01:44:04 CDT IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
01:44:05 CDT lo 0.000.000.000.000.000.000.00
01:44:05 CDT eth0 162.14156.31107.4642.180.000.000.00
01:44:05 CDT eth1 135.92138.8339.38104.920.000.000.00
01:44:05 CDT IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
01:44:06 CDT lo 0.000.000.000.000.000.000.00
01:44:06 CDT eth0 303.92293.14272.9137.400.000.000.00
01:44:06 CDT eth1 252.94290.2034.87263.500.000.000.00
Average: IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
Average: lo 0.000.000.000.000.000.000.00
Average: eth0 210.37202.34163.1935.660.000.000.00
Average: eth1 178.93191.6433.36171.600.000.000.00
via: http://www.cyberciti.biz/faq/network-statistics-tools-rhel-centos-debian-linux/
本文永久更新連結地址:http://www.linuxidc.com/Linux/2015-06/118533.htm
相關文章