首页 > 代码库 > 查看tcp连接数,状态命令
查看tcp连接数,状态命令
ss与netstat效率对比。ss更快些,且netstat在并发高于2万情况下会有严重的卡顿现象
[root@zabbix zabbix]#time ss state all|awk ‘{++S[$1]} END {for (a in S) {printf "%11-s %s\n",a,S[a]}}‘ #不是LL,是2个1
ESTAB 1
State 1
TIME-WAIT 5
LISTEN 13
real 0m0.005s
user 0m0.002s
sys 0m0.002s
[root@zabbix zabbix]# time netstat -an|awk ‘/^tcp/ {++s[$NF]} END {for ( a in s ) {printf "%11-s %s\n",a,s[a]}}‘ #不是LL,是2个1
TIME_WAIT 9
ESTABLISHED 1
LISTEN 13
real 0m0.008s
user 0m0.002s
sys 0m0.004s
监控tcp连接状态可查看/proc/net/tcp文件
[root@zabbix zabbix]# tail -3 /proc/net/tcp #第4列绿色为tcp的各种状态
5: 00000000:CE74 00000000:0000 0A 00000000:00000000 00:00000000 00000000 29 0 10581 1 ffff880036b42040 99 0 0 10 -1
6: 5100000A:8F4C 07AC2A79:0050 06 00000000:00000000 03:00000FA1 00000000 0 0 0 3 ffff88001de8aec0
7: 5100000A:0016 0100000A:D7D0 01 00000040:00000000 01:00000018 00000000 0 0 185660 4 ffff8800185bf180 24 3 21 6 4
本文出自 “11934901” 博客,请务必保留此出处http://11944901.blog.51cto.com/11934901/1939790
查看tcp连接数,状态命令