1 统计80端口连接数
netstat -nat|grep -i "80"|wc -l
2 统计httpd协议连接数
ps -ef|grep httpd|wc -l
3 统计已连接上的,状态为“established
netstat -na|grep ESTABLISHED|wc -l
4 查出哪个IP地址连接最多
netstat -na|grep ESTABLISHED|awk {print $5}|awk -F: {print $1}|sort|uniq -c|sort -r +0n
netstat -na|grep SYN|awk {print $5}|awk -F: {print $1}|sort|uniq -c|sort -r +0n
5 查出连接
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
TIME_WAIT 72452
CLOSE_WAIT 267
FIN_WAIT1 20
SYN_SENT 143
FIN_WAIT2 102
ESTABLISHED 4229
CLOSING 2
LAST_ACK 23