Linux服务器当前各种TCP网络连接状态的统计
来源:互联网 发布:mac版八爪鱼软件 编辑:程序博客网 时间:2024/06/06 08:47
例如服务器上的TCP网络连接状态显示如下:
[root@www.codesky.net ~]# netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:554 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:1935 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:3001 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:1947 0.0.0.0:* LISTEN
tcp 0 0 172.16.6.93:80 172.16.6.93:51201 ESTABLISHED
tcp 0 0 172.16.6.93:80 172.16.6.93:51202 ESTABLISHED
tcp 0 0 172.16.6.93:10050 172.16.3.112:32769 TIME_WAIT
tcp 0 0 172.16.6.93:51201 172.16.6.93:80 ESTABLISHED
tcp 0 0 172.16.6.93:51202 172.16.6.93:80 ESTABLISHED
tcp 0 1 172.16.6.93:53276 172.16.3.162:8080 SYN_SENT
tcp 0 0 :::22 :::* LISTEN
tcp 0 844 ::ffff:172.16.6.93:22 ::ffff:172.16.1.36:56495 ESTABLISHED
统计命令和计算结果如下:
[root@www.codesky.net ~]# netstat -nat | awk 'FNR>2{print $NF}' | sort | uniq -c
5 ESTABLISHED
9 LISTEN
1 TIME_WAIT
参数说明:
netstat -nat 参数t表示只列出tcp连接
TCP连接状态的定义:
ESTABLISHED
The socket has an established connection.
SYN_SENT
The socket is actively attempting to establish a connection.
SYN_RECV
A connection request has been received from the network.
FIN_WAIT1
The socket is closed, and the connection is shutting down.
FIN_WAIT2
Connection is closed, and the socket is waiting for a shutdown from the remote end.
TIME_WAIT
The socket is waiting after close to handle packets still in the network.
CLOSED The socket is not being used.
CLOSE_WAIT
The remote end has shut down, waiting for the socket to close.
LAST_ACK
The remote end has shut down, and the socket is closed. Waiting for acknowledgement.
LISTEN The socket is listening for incoming connections. Such sockets are not included in the output
unless you specify the --listening (-l) or --all (-a) option.
CLOSING
Both sockets are shut down but we still don’t have all our data sent.
UNKNOWN
The state of the socket is unknown.
详细请参考:http://www.codesky.net/article/201110/173757.html
[root@www.codesky.net ~]# netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:554 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:1935 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:3001 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:1947 0.0.0.0:* LISTEN
tcp 0 0 172.16.6.93:80 172.16.6.93:51201 ESTABLISHED
tcp 0 0 172.16.6.93:80 172.16.6.93:51202 ESTABLISHED
tcp 0 0 172.16.6.93:10050 172.16.3.112:32769 TIME_WAIT
tcp 0 0 172.16.6.93:51201 172.16.6.93:80 ESTABLISHED
tcp 0 0 172.16.6.93:51202 172.16.6.93:80 ESTABLISHED
tcp 0 1 172.16.6.93:53276 172.16.3.162:8080 SYN_SENT
tcp 0 0 :::22 :::* LISTEN
tcp 0 844 ::ffff:172.16.6.93:22 ::ffff:172.16.1.36:56495 ESTABLISHED
统计命令和计算结果如下:
[root@www.codesky.net ~]# netstat -nat | awk 'FNR>2{print $NF}' | sort | uniq -c
5 ESTABLISHED
9 LISTEN
1 TIME_WAIT
参数说明:
netstat -nat 参数t表示只列出tcp连接
awk 'FNR>2{print $NF}' FNR表示这条记录的行号,NF表示这一条记录中的字段总数
TCP连接状态的定义:
ESTABLISHED
The socket has an established connection.
SYN_SENT
The socket is actively attempting to establish a connection.
SYN_RECV
A connection request has been received from the network.
FIN_WAIT1
The socket is closed, and the connection is shutting down.
FIN_WAIT2
Connection is closed, and the socket is waiting for a shutdown from the remote end.
TIME_WAIT
The socket is waiting after close to handle packets still in the network.
CLOSED The socket is not being used.
CLOSE_WAIT
The remote end has shut down, waiting for the socket to close.
LAST_ACK
The remote end has shut down, and the socket is closed. Waiting for acknowledgement.
LISTEN The socket is listening for incoming connections. Such sockets are not included in the output
unless you specify the --listening (-l) or --all (-a) option.
CLOSING
Both sockets are shut down but we still don’t have all our data sent.
UNKNOWN
The state of the socket is unknown.
详细请参考:http://www.codesky.net/article/201110/173757.html
- Linux服务器当前各种TCP网络连接状态的统计
- Linux服务器当前各种TCP网络连接状态的统计
- 网络编程:如何取得当前各种网络连接的状态
- netstat查看当前网络下TCP的各种状态
- tcp的各种连接状态
- TCP连接的各种状态
- linux 下获取当前网络连接状态
- 统计连接数状态(Linux网络连接状态检查!)
- 显示协议统计信息和当前 TCP/IP 网络连接。
- Linux服务器上11种网络连接状态 和 TCP三次握手/四次挥手详解
- 【转】Linux服务器上11种网络连接状态 和 TCP三次握手/四次挥手详解
- netstat查看linux服务器网络连接状态
- netstat查看linux服务器网络连接状态
- 判断各种网络的连接状态
- 系统tcp 连接状态统计
- Linux命令学习:统计socket各种状态的连接数(sed/awk)
- 在linux服务器中查看当前连接统计数的命令
- TCP的各种状态
- 我的参考四班三倒
- 运算重载符学习
- Visual Studio控制台程序输出窗口一闪而过的解决方法
- 5.2
- ms sql 2008 修改sa密码
- Linux服务器当前各种TCP网络连接状态的统计
- android+最新adk+cdt配置ndk开发环境简要笔记
- 今天星期几js
- 【jquery】find()方法和each()方法
- Brup Suite使用
- HDU 3400 Line belt (三分搜索)
- SQLiteOpenHelper数据库打开连接帮助类使用说明
- 查看SQL Server error log
- jMeter Webservice测试计划