-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog_processing.py
More file actions
37 lines (31 loc) · 793 Bytes
/
log_processing.py
File metadata and controls
37 lines (31 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import re
cr = re.compile("closing connction ([^ \n]*)")
wr = re.compile("Writer task send to node_id ([^ \n]*)")
lr = re.compile("looping through")
p = {}
m = 0
mx =0
for i in open("/home/abhinav/log_2017-02-03_05-15.txt").xreadlines():
a = cr.findall(i)
if(a):
if(a[0] in p):
p[a[0]][1]+=1
else:
p[a[0]] = [0,1]
continue
b = wr.findall(i)
if(b):
if(b[0] in p):
p[b[0]][0]+=1
else:
p[b[0]] = [1,0]
continue
if(lr.search(i)!=None):
m+=1
mx = max(m, mx)
continue
m=0
sorted_x = sorted(p.items(), key=lambda x: abs(x[1][0] - x[1][1]) , reverse=True)
for i in range(0, 100):
print sorted_x[i]
print mx