log.py
This commit is contained in:
parent
6fbf265e6e
commit
7cc40880fc
189759
sio2/sisr/35-script/python/access.log
Normal file
189759
sio2/sisr/35-script/python/access.log
Normal file
File diff suppressed because it is too large
Load Diff
19
sio2/sisr/35-script/python/log.py
Normal file
19
sio2/sisr/35-script/python/log.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#/usr/bin/python3
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
group = {}
|
||||||
|
regexp = '^(\S+) (\S+) (\S+) \[([^]]+)\] "(\w+) (\S+).*" (\d+) (\S+)'
|
||||||
|
for line in sys.stdin:
|
||||||
|
line = line.rstrip ( )
|
||||||
|
match = re.match (regexp, line)
|
||||||
|
if match:
|
||||||
|
print (match.group(1)," ",match.group(8))
|
||||||
|
ip = match.group(1)
|
||||||
|
vol = match.group(8)
|
||||||
|
if ip in group:
|
||||||
|
group[ip] = group[ip] + vol
|
||||||
|
else:
|
||||||
|
group[ip] = vol
|
||||||
|
for key in group.keys():
|
||||||
|
print (key, " ", group[key])
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user