- 论坛徽章:
- 0
|
#/usr/bin/python
upstream = 0
downstream = 0
serverup_dic = {}
serverdown_dic = {}
file_object = open('/root/ipall.txt','r')
for x in file_object:
list = x.split()
list[3] = list[3][4:15]
list[4] = list[4][:-1]
list[5] = list[5][0:12]
if list[1] == "1":
upstream = upstream + int(list[6])
downstream = downstream + int(list[7])
if serverup_dic.has_key(list[0]):
serverup_dic[list[0]] = serverup_dic[list[0]] + int(list[6])
else:
serverup_dic[list[0]] = int(list[6])
if serverdown_dic.has_key(list[0]):
serverdown_dic[list[0]] = serverup_dic[list[0]] + int(list[7])
else:
serverdown_dic[list[0]] = int(list[7])
print list
print "the server 1 upload traffic is %uk" % upstream
print "the server 1 load traffic is %uk" % downstream
for key,value in serverup_dic.items():
print "phone %s upload traffic is %uk" % (key,value)
for key,value in serverdown_dic.items():
print "phone %s download traffic is %uk" % (key,value)
file_object.close() |
|