Linux性能测试 netstat命令
功能说明:Netstat用于显示与IP、TCP、UDP和ICMP协议相关的统计数据,一般用于检验本机各端口的网络连接情况。
语 法:netstat [-acCeFghilMnNoprstuvVwx][-A<网络类型>][--ip]
补充说明:利用netstat指令可让你得知整个Linux系统的网络情况。
参 数:
-a或–all 显示所有连线中的Socket。
-A<网络类型>或–<网络类型> 列出该网络类型连线中的相关地址。
-c或–continuous 持续列出网络状态。
-C或–cache 显示路由器配置的快取信息。
-e或–extend 显示网络其他相关信息。
-F或–fib 显示FIB。
-g或–groups 显示多重广播功能群组组员名单。
-h或–help 在线帮助。
-i或–interfaces 显示网络界面信息表单。
-l或–listening 显示监控中的服务器的Socket。
-M或–masquerade 显示伪装的网络连线。
-n或–numeric 直接使用IP地址,而不通过域名服务器。
-N或–netlink或–symbolic 显示网络硬件外围设备的符号连接名称。
-o或–timers 显示计时器。
-p或–programs 显示正在使用Socket的程序识别码和程序名称。
-r或–route 显示Routing Table。
-s或–statistice 显示网络工作信息统计表。
-t或–tcp 显示TCP传输协议的连线状况。
-u或–udp 显示UDP传输协议的连线状况。
-v或–verbose 显示指令执行过程。
-V或–version 显示版本信息。
-w或–raw 显示RAW传输协议的连线状况。
-x或–unix 此参数的效果和指定”-A unix”参数相同。
–ip或–inet 此参数的效果和指定”-A inet”参数相同
netstat 的一些常用选项
netstat -s
本选项能够按照各个协议分别显示其统计数据。如果我们的应用程序(如Web浏览器)运行速度比较慢,或者不能显示Web页之类的数据,那么我们就可以用本选项来查看一下所显示的信息。我们需要仔细查看统计数据的各行,找到出错的关键字,进而确定问题所在。
[root@SM155 proc]# netstat -s Ip: 8530928 total packets received 0 forwarded 0 incoming packets discarded 6972819 incoming packets delivered 8521573 requests sent out 1 fragments dropped after timeout 39629 reassemblies required 19667 packets reassembled ok 1 packet reassembles failed Icmp: 16023 ICMP messages received 175 input ICMP message failed. ICMP input histogram: destination unreachable: 4362 echo requests: 11661 19476 ICMP messages sent 0 ICMP messages failed ICMP output histogram: destination unreachable: 7815 echo replies: 11661 Tcp: 1651264 active connections openings 159526 passive connection openings 197 failed connection attempts 150104 connection resets received 31 connections established 6439010 segments received 6739834 segments send out 423 segments retransmited 0 bad segments received. 1649444 resets sent Udp: 135397 packets received 7341 packets to unknown port received. 0 packet receive errors 1762263 packets sent TcpExt: ArpFilter: 0 800 TCP sockets finished time wait in fast timer 300 time wait sockets recycled by time stamp 8850 delayed acks sent 1 delayed acks further delayed because of locked socket Quick ack mode was activated 12 times 552580 packets directly queued to recvmsg prequeue. 296789 packets directly received from prequeue 724223 packets header predicted 11117 packets header predicted and directly queued to user TCPPureAcks: 249691 TCPHPAcks: 1235152 TCPRenoRecovery: 0 TCPSackRecovery: 1 TCPSACKReneging: 0 TCPFACKReorder: 0 TCPSACKReorder: 0
netstat -e
本选项用于显示关于以太网的统计数据。它列出的项目包括传送的数据报的总字节数、错误数、删除数、数据报的数量和广播的数量。这些统计数据既有发送的数据报数量,也有接收的数据报数量。这个选项可以用来统计一些基本的网络流量)。
[root@SM155 proc]# netstat -e Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State User Inode tcp 0 0 10.90.243.155:49182 10.90.243.27:32931 ESTABLISHED root 382858 tcp 0 0 localhost.localdomain:49176 localhost.localdomain:39918 ESTABLISHED root 24542 tcp 1 0 10.90.243.155:64766 10.90.243.27:951 CLOSE_WAIT root 3239351 tcp 0 0 localhost.localdomain:39015 localhost.localdomain:49178 ESTABLISHED root 24546 tcp 0 0 localhost.localdomain:39016 localhost.localdomain:49179 ESTABLISHED root 24548 tcp 0 0 10.90.243.155:ssh 10.88.22.243:3672 ESTABLISHED root 6062002
netstat -r
本选项可以显示关于路由表的信息,类似于后面所讲使用route print命令时看到的 信息。除了显示有效路由外,还显示当前有效的连接。
[root@SM155 proc]# netstat -r Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 10.90.243.0 * 255.255.255.0 U 0 0 0 eth0 10.10.10.0 * 255.255.255.0 U 0 0 0 eth1 169.254.0.0 * 255.255.0.0 U 0 0 0 eth1 default 10.90.243.1 0.0.0.0 UG 0 0 0 eth0 [root@SM155 proc]#
netstat -a
本选项显示一个所有的有效连接信息列表,包括已建立的连接(ESTABLISHED),也包括监听连接请(LISTENING)的那些连接。
[root@SM155 proc]# netstat -a Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 10.90.243.155:39010 *:* LISTEN tcp 0 0 *:shell *:* LISTEN tcp 0 0 10.90.243.155:39011 *:* LISTEN tcp 0 0 *:39012 *:* LISTEN tcp 0 0 *:39015 *:* LISTEN tcp 0 0 *:49159 *:* LISTEN tcp 0 0 localhost.localdomain:39016 *:* LISTEN tcp 0 0 *:49166 *:* LISTEN tcp 0 0 *:39918 *:* LISTEN tcp 0 0 *:sunrpc *:* LISTEN tcp 0 0 *:49173 *:* LISTEN tcp 0 0 *:ftp *:* LISTEN tcp 0 0 *:ssh *:* LISTEN tcp 0 0 *:13819 *:* LISTEN tcp 0 0 *:2812 *:* LISTEN tcp 0 0 10.90.243.155:49182 *:* LISTEN tcp 0 0 10.90.243.155:49182 10.90.243.27:32931 ESTABLISHED tcp 0 0 localhost.localdomain:49176 localhost.localdomain:39918 ESTABLISHED tcp 1 0 10.90.243.155:64766 10.90.243.27:951 CLOSE_WAIT tcp 0 0 localhost.localdomain:39015 localhost.localdomain:49178 ESTABLISHED tcp 0 0 localhost.localdomain:39016 localhost.localdomain:49179 ESTABLISHED
netstat -n
显示所有已建立的有效连接。
[root@SM155 proc]# netstat -n Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 10.90.243.155:49182 10.90.243.27:32931 ESTABLISHED tcp 0 0 127.0.0.1:49176 127.0.0.1:39918 ESTABLISHED tcp 1 0 10.90.243.155:64766 10.90.243.27:951 CLOSE_WAIT tcp 0 0 127.0.0.1:39015 127.0.0.1:49178 ESTABLISHED tcp 0 0 127.0.0.1:39016 127.0.0.1:49179 ESTABLISHED tcp 0 0 127.0.0.1:39918 127.0.0.1:49176 ESTABLISHED tcp 0 0 10.90.243.155:58692 10.90.243.155:39010 ESTABLISHED tcp 0 0 10.90.243.155:39012 10.90.243.155:49168 ESTABLISHED tcp 0 0 127.0.0.1:39012 127.0.0.1:49174 ESTABLISHED tcp 0 0 10.90.243.155:39012 10.90.243.155:49175 ESTABLISHED tcp 0 0 127.0.0.1:39012 127.0.0.1:49160 ESTABLISHED tcp 0 0 10.90.243.155:39012 10.90.243.155:49161 ESTABLISHED tcp 0 0 127.0.0.1:39012 127.0.0.1:49167 ESTABLISHED tcp 0 0 10.90.243.155:49185 10.90.243.155:39011 ESTABLISHED tcp 0 0 127.0.0.1:49174 127.0.0.1:39012 ESTABLISHED tcp 0 0 10.90.243.155:49175 10.90.243.155:39012 ESTABLISHED tcp 0 0 10.90.243.155:49168 10.90.243.155:39012 ESTABLISHED tcp 0 0 127.0.0.1:49167 127.0.0.1:39012 ESTABLISHED tcp 0 0 127.0.0.1:49160 127.0.0.1:39012 ESTABLISHED tcp 0 0 10.90.243.155:49161 10.90.243.155:39012 ESTABLISHED tcp 0 0 10.90.243.155:49159 10.90.243.155:58726 ESTABLISHED tcp 0 0 127.0.0.1:49178 127.0.0.1:39015 ESTABLISHED
本文来自博客园,作者:方倍工作室,转载请注明原文链接:https://www.cnblogs.com/txw1958/archive/2012/07/26/linux-netstat.html