netstat -Aan|grep -v CLOSED|while read cb
do
echo $cb | cut -d' ' -f1 | xargs -i rmsock {} tcpcb 2>/dev/null |
perl -ne 'print $1,"\n" if /proccess (\d+)/' |
xargs -i ps -fp {}|grep -v UID|
awk '{printf "%s\t%s\t%s\n",$1,$2,$NF}'|
sed -e "s|$| $cb|"
done | awk '
BEGIN{
tot=0;
count[""]=0;
}{
#print $0;
tot++;
count[$3]++;
}END{
print "--------------------"
for (i in count){
if(i!="")print count[i], i;
}
print "--------------------"
print tot, "total";
}'
Advertisement