#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import re
import stat
import os.path
import time
mr = re.compile(r'CMM_FETCH_MAIL')
pat = re.compile(r'\]\[(\d\d:\d\d):\d\d\.\d+\].*?CMM_FETCH_MAIL.*?mail_size=(\d+)\| queue_up_time=(\d+)\| fetch_mail_time=(\d+)\|.*? time=(\d+)\|')
hashmailsize = {}
file = '/logs/rm_bk/r-09_172.16.183.39/mv.log'
f = open(file , "r")
readlines = f.readlines()
for i in readlines:
# print "%s" % i
mar = mr.search(i)
if mar:
#print "%s" % i
if pat.search(i):
logtime = pat.search(i).group(1)
mailsize = pat.search(i).group(2)
queue_up_time = pat.search(i).group(3)
fetch_mail_time= pat.search(i).group(4)
mailtime = pat.search(i).group(5)
if hashmailsize.has_key('svr'):
if hashmailsize['svr'].has_key(logtime):
hashmailsize['svr'][logtime] +=1
else:
hashmailsize['svr'][logtime] =1
else:
hashmailsize['svr']={}
hashmailsize['svr'][logtime] =1
#print "logtime %s mailsize %s queue_up_time %s fetch_mail_time %s mailtime %s" % (logtime, mailsize, queue_up_time, fetch_mail_time, mailtime)
keyz = hashmailsize.keys()
keyz.sort()
for v in keyz:
keym = hashmailsize[v].keys()
keym.sort()
for vv in keym:
print "key %s value %s " % (vv, hashmailsize[v][vv])