分类: LINUX
2011-11-21 15:14:24
netstat -ant |awk '/:80/{split($5,ip,":");++A[ip[1]]}END{for(i in A) print
A[i],i}' |sort -rn
查看IP数
netstat -n | awk '/^tcp/
{++state[$NF]} END {for(key in state) print key,"\t",state[key]}'
查看网络链接数
查看当前每个IP的连接数、TCP连接状态、统计IP数、总的连接数:
netstat -n | awk '/^tcp/
{n=split($(NF-1),array,":");if(n<=2)++S[array[(1)]];else++S[array[(4)]];++s[$NF];++N}
END {for(a in S){printf("%-20s %s\n", a, S[a]);++I}printf("%-20s
%s\n","TOTAL_IP",I);for(a in s) printf("%-20s %s\n", a, s[a]);printf("%-20s
%s\n","TOTAL_LINK",N);}'