现在的位置: 首页 > 综合 > 正文

统计出所有用户的连接数情况

2013年04月28日 ⁄ 综合 ⁄ 共 421字 ⁄ 字号 评论关闭

这是对前一篇的补充,前一篇只是正对某一个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

抱歉!评论已关闭.