这是对前一篇的补充,前一篇只是正对某一个IP进行统计,这个则是统计出所有的连接数
#!/bin/sh
#current connectons report
usage()
{
echo "examples:"
echo "conns"
echo "conns -d"
exit 1
}
if [ $# -ge 2 ];then
usage
fi
if [ $# -eq 0 ];then
netstat -an | awk '{print substr($4,1,index($4,":")-1),substr($5,1,index($5,":")-1)}' | sort | uniq -c | head
fi
if [ $# -eq 1 ];then
netstat -an | awk '{print substr($4,1,index($4,":")-1),substr($5,1,index($5,":")-1)}' | sort | uniq -c
fi