diff --git a/sio2/sisr/20-python/log.py b/sio2/sisr/20-python/log.py new file mode 100644 index 0000000..13f648d --- /dev/null +++ b/sio2/sisr/20-python/log.py @@ -0,0 +1,22 @@ +#/usr/bien/python3 + +import re +import sys + +cptip = {} +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 = int(match.group(8)) + if ip in cptip : + cptip[ip] = cptip[ip] + vol + else: + cptip[ip] = vol + +for key in cptip.keys(): + print(key, ":", cptip[key])