Ejemplo n.º 1
0
def DataAggregateWork(sourcedata):
    global g_dealOnelogTIme
    timed = int(round(time.time() * 1000)) - g_dealOnelogTIme
    g_dealOnelogTIme = int(round(time.time() * 1000))
    global g_logcount

    g_logobj.logger.info(
        "deal  proxy log-------------time=%d-----------count=%d" %
        (timed, g_logcount))
    print "------log-------------time=%d-----------count=%d" % (timed,
                                                                g_logcount)
    g_logcount += 1
    Onelog = Clogdata()
    Onelog.SetAttr(sourcedata)
    Onelog.country = updateIPmapping(Onelog.destip, g_mysqlInst)
    #//--在整合之前,添加业务接口,统计业务信息-//
    StatEveryLog(Onelog)
    Uniqueident = Onelog.tid + Onelog.CM_to
    if Uniqueident in g_logdict.keys():
        g_logdict[Uniqueident].reFleshAtrr(Onelog)
        return 0
    else:
        if len(g_logdict) < g_dictMaxCapacitySize:
            g_logdict[Uniqueident] = Onelog
            return 0
        else:
            return -1
Ejemplo n.º 2
0
 def __init__(self, sourceRecord):
     global g_Deliverid
     self.ErrorCode = getStatusCode(sourceRecord.Originaldesc,
                                    sourceRecord.result)[0]
     self.detail = getStatusCode(sourceRecord.Originaldesc,
                                 sourceRecord.result)[1]
     self.time = sourceRecord.logCreatedate
     print self.time
     self.time = self.time[:self.time.find(".")]
     self.timestamp = int(
         time.mktime(time.strptime(self.time, "%Y-%m-%dT%H:%M:%S")))
     self.timestamp1 = int(
         time.mktime(time.strptime(self.time, "%Y-%m-%dT%H:%M:%S")))
     self.timestamp2 = int(
         time.mktime(time.strptime(self.time, "%Y-%m-%dT%H:%M:%S")))
     self.NumofCode = 1
     self.Proxyip = sourceRecord.bindip
     self.DAFailtoDeliver = 0
     self.DAsucceedDelv = 0
     self.Proxydelay = sourceRecord.optime  #每台proxy的国家投递性能
     self.DAproxydelay = sourceRecord.optime
     if (sourceRecord.result == 1):
         self.DAFailtoDeliver = 1  #当前失败次数
         self.DAsucceedDelv = 0
     elif (sourceRecord.result == 0):
         self.DAsucceedDelv = 1
         self.DAFailtoDeliver = 0
     self.SumofDASucceed = self.DAsucceedDelv
     self.SumofDAFailure = self.DAFailtoDeliver
     self.SumofDADeliver = 1
     self.FailrateofDeliver = 0.0
     self.Countrydict = {}
     self.proxyCountry = updateIPmapping(sourceRecord.bindip, mysqlInst)
     self.ForCtySumofproxysucceedDeliver = self.DAsucceedDelv
     self.ForCtySumofproxyDelv = 1
     self.ForCtyproxyDeliverRate = 1 - float(self.DAsucceedDelv) / float(
         self.ForCtySumofproxyDelv)
     self.did = g_Deliverid
     self.did1 = g_Deliverid
     self.did2 = g_Deliverid
     self.size = ""
     forCtyProxydict = {}
     g_Deliverid += 1
Ejemplo n.º 3
0
def refreshTimeCount():
    global g_logobj
    g_logobj.logger.info("the g_logdict size=%d"%(len(g_logdict)))
    for dkey,dvalue in g_logdict.items():
        dvalue.CM_TimeCount+=1
        if(dvalue.CM_status=="succeed" or dvalue.CM_status=="fail" or dvalue.CM_TimeCount>=g_logkeepTimeCountmax):
            #投递给ES
            #从g_logdict删除
            if(dvalue.CM_TimeCount>=g_logkeepTimeCountmax):
                dvalue.CM_status="overtime"
            dvalue.country = updateIPmapping(dvalue.destip,g_mysqlInst)
            Deliver2ESWithpath(dvalue.Data2Json(),"everymail","log",dvalue.CM_Index)
            #业务功能 邮件走势量
            StatmailInfo(dvalue)
            global mailCount
            g_logobj.logger.info("Delieve to everymail succeed------------------------------count=%d"%(mailCount))
            print "Delieve succeed------------------------------count=%d"%(mailCount)
            mailCount+=1
            g_logdict.pop(dkey)
Ejemplo n.º 4
0
    def __init__(self, sourceRecord):
        global g_rejectrateid
        self.recipDomain = sourceRecord.CM_to[sourceRecord.CM_to.find('@') +
                                              1:]
        self.Forrecipreturn = 0
        self.ForCtyreturn = 0
        self.Sumofreturn = 0
        self.SumofSucceed = 0
        self.SumofThridError = 0
        self.ForCtyNumofsucceed = 0
        if (sourceRecord.result == 1):
            self.Forrecipreturn = 1
            self.ForCtyreturn = 1
            self.Sumofreturn = 1
            self.SumofSucceed = 0
            self.SumofThridError = 0
            self.ForCtyNumofsucceed = 0
        elif (sourceRecord.result == 0):
            self.Forrecipreturn = 0
            self.ForCtyreturn = 0
            self.Sumofreturn = 0
            self.SumofSucceed = 1
            self.SumofThridError = 0
            self.ForCtyNumofsucceed = 1
        else:
            self.Forrecipreturn = 0
            self.ForCtyreturn = 0
            self.Sumofreturn = 0
            self.SumofSucceed = 0
            self.SumofThridError = 1
            self.ForCtyNumofsucceed = 0
        self.ForrecipSendmail = 1
        self.ForrecipRejectrate = float(self.Forrecipreturn) / float(
            self.ForrecipSendmail)

        self.time = sourceRecord.logCreatedate  #datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        self.timestamp = int(
            time.mktime(time.strptime(self.time, "%Y-%m-%d %H:%M:%S")))
        self.timestamp1 = int(
            time.mktime(time.strptime(self.time, "%Y-%m-%d %H:%M:%S")))
        self.timestamp2 = int(
            time.mktime(time.strptime(self.time, "%Y-%m-%d %H:%M:%S")))
        self.timestamp3 = int(
            time.mktime(time.strptime(self.time, "%Y-%m-%d %H:%M:%S")))

        self.sendid = g_rejectrateid
        self.sendid1 = g_rejectrateid
        self.sendid2 = g_rejectrateid
        self.sendid3 = g_rejectrateid
        g_rejectrateid += 1
        self.SumofDeliver = 1

        self.SumofFailrate = 1.0 - float(self.SumofSucceed) / float(
            self.SumofDeliver)

        self.ToCountry = updateIPmapping(sourceRecord.bindip, mysqlInst)
        self.ForCtyNumofdlv = 1
        self.ForCtyFailrate = 1.0 - float(self.ForCtyNumofsucceed) / float(
            self.ForCtyNumofdlv)

        self.ForrecipaveDelay = sourceRecord.CM_AllTime
        self.Forrecipmaxdelay = sourceRecord.CM_AllTime
        self.ForrecipThisdelay = sourceRecord.CM_AllTime

        self.SenderDomain = sourceRecord.CM_from[sourceRecord.CM_from.
                                                 find('@') + 1:]
        self.ForSenderaveDelay = sourceRecord.CM_AllTime
        self.ForSendermaxdelay = sourceRecord.CM_AllTime
        self.ForSenderThisdelay = sourceRecord.CM_AllTime
        self.ForSenderDelvier = 1