计算重复的IP出现次数
时间:2008-11-27 来源:lengyuzlg
import os,string
m=[]
n={}
s=os.popen('netstat -n')
for i in s.readlines():
l=string.split(i)
if len(l)>6:
pass
elif len(l)<6:
pass
else:
m.append(l[4])
for elen in m:
if m.count(elen)==1:
pass
else:
n[elen]=(m.count(elen))
t=sorted(n.items(),key=lambda d: d[1],reverse=True)
#for i,k in t:
# print i,k
for i in t:
print i[0],i[1]
m=[]
n={}
s=os.popen('netstat -n')
for i in s.readlines():
l=string.split(i)
if len(l)>6:
pass
elif len(l)<6:
pass
else:
m.append(l[4])
for elen in m:
if m.count(elen)==1:
pass
else:
n[elen]=(m.count(elen))
t=sorted(n.items(),key=lambda d: d[1],reverse=True)
#for i,k in t:
# print i,k
for i in t:
print i[0],i[1]
相关阅读 更多 +