#/bin/bash
date
netstat -an | grep 1088 | awk '{print $5}'>iplist.txt #按应用端口匹配
echo "************************************************"
echo "The total of connections is `netstat -an | grep -c 1088`."
echo "************************************************"
echo "The total of different types of connections:"
netstat -an | grep 1088 | awk '{count[$6]++}END{for(i in count)print i,count[i]}' | sort -nrt ' ' -k 2 #按类型显示连接
echo "************************************************"
sed -i 's/::ffff://' iplist.txt
sed -i '/^:::/d' iplist.txt
sed -i 's/:[0-9]\{4,5\}//' iplist.txt
cat iplist.txt | sort | uniq -c | sort -nr | awk '{print "IP",$2,"has",$1,"connections."}' | head -10
阅读(1188) | 评论(0) | 转发(0) |