#/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
执行效果如图所示
a2.jpg
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26904975/viewspace-750299/
,如需转载,请注明出处,否则将追究法律责任。