在日常运维中,经常有数据库连接过多,但是又不知道是哪些连接,所以可以通过用netstat,awk,sort,uniq,cut,sed组合找到我们想要的答案
netstat分组统计源ip连接数量
命令如下:
netstat -ant |awk ‘{print $5}’|cut -d “:” -f1|sort |uniq -c |sort -nr |head -10
结果如下:
[root@host-03 ~]# netstat -ant |awk '{print $5}'|cut -d ":" -f1|sort |uniq -c |sort -nr |head -10
219 172.20.27.94
184 172.20.27.93
173 172.20.27.95
38 0.0.0.0
31
8 172.20.27.135


1311

被折叠的 条评论
为什么被折叠?



