本节内容:
linuxjishu/13830.html target=_blank class=infotextkey>awk查看ip连接数
例1:[jbxue@localhost ~]
说明:$5是netstat –an 第5个字段。默认就是对方连接ip以及端口。
例2,[jbxue@localhost ~]$
time awk 'BEGIN{while("netstat -an"|getline){if( $5 ~ /[1-255]/){split($5,t1,":");tarr[t1[1]]++;}}for(k in tarr){print k,tarr[k] | "sort -r -n -k2";}};'
211.151.33.14 28
113.65.21.200 14
121.32.89.106 13
60.191.178.230 12
118.133.177.104 12
58.61.152.154 11
219.137.58.20 11
124.117.248.52 11
122.198.80.145 11
222.88.15.138 10
222.44.13.191 10
222.161.47.34 10
221.4.202.210 10
218.79.64.12 10
183.17.92.193 10
120.72.128.254 10
118.118.121.244 10
116.252.38.236 10
113.248.75.44 10
real 0m1.149s
user 0m0.032s
sys 0m1.055s