Example #1
0
 def sendMail( self, msgID, msgDetail ):
     mailTitle = msgDetail[ 'title' ]
     mailBody = self.buildMailBody( msgID, msgDetail )
     toMailList = self.toEmailList[ msgDetail[ 'msgLevel' ] ]
     gexingServiceMailObj =  sendMail.gexingServiceMail( self.fromEmailInfo[ 'fromEmail' ] , self.fromEmailInfo[ 'fromEmailPwd' ] )
     gexingServiceMailObj.send( mailTitle, mailBody, toMailList )
     self.logObj.info( "send email complete!to("+( '.'.join( toMailList ) )+")title("+mailTitle+")mailBody("+mailBody+")" )
Example #2
0
 def sendMail(self, msgID, msgDetail):
     mailTitle = msgDetail['title']
     mailBody = self.buildMailBody(msgID, msgDetail)
     toMailList = self.toEmailList[msgDetail['msgLevel']]
     gexingServiceMailObj = sendMail.gexingServiceMail(
         self.fromEmailInfo['fromEmail'],
         self.fromEmailInfo['fromEmailPwd'])
     gexingServiceMailObj.send(mailTitle, mailBody, toMailList)
     self.logObj.info("send email complete!to(" + ('.'.join(toMailList)) +
                      ")title(" + mailTitle + ")mailBody(" + mailBody + ")")
 def sendMergeMail(self, queueNode):
     toMailList = self.conf['msgFilterMail']['mergemaillist'].split(",")
     mailTitle, mailBody = self.buildMailTitleBody(queueNode)
     gexingServiceMailObj = sendMail.gexingServiceMail(
         self.fromEmailInfo['fromEmail'],
         self.fromEmailInfo['fromEmailPwd'])
     gexingServiceMailObj.send(mailTitle, mailBody, toMailList)
     self.logObj.info("send msgFilter merge email by Content complete!to(" +
                      ('.'.join(toMailList)) + ")title(" + mailTitle +
                      ")mailBody(" + mailBody + ")")
Example #4
0
    def sendMail( self, msgNode ):
        #alertData['500']['requestCount']=10
        #         ['www.gexing.com'][200]['requestCount']=5
        #

	print( msgNode )
        mailTitle = self.alertEmailTitleTmpl.replace( '__TITLE__', "[key filter alert]"+(" ".join(msgNode)) )
        mailBody = self.alertEmailBodyTmpl.replace( '__BODY__', " ".join(msgNode) )

        globalVariable.totalEmailCount += 1
        toMailList = self.toEmailList[ 'warning' ]
        gexingServiceMailObj =  sendMail.gexingServiceMail( self.fromEmailInfo[ 'fromEmail' ] , self.fromEmailInfo[ 'fromEmailPwd' ] )
        gexingServiceMailObj.send( mailTitle, mailBody, toMailList )
        self.logObj.info( "sendmail complete!to("+( '.'.join( toMailList ) )+")title("+mailTitle+")mailBody("+mailBody+")" )
    def sendMail(self, msgNode):
        #alertData['500']['requestCount']=10
        #         ['www.gexing.com'][200]['requestCount']=5
        #

        print(msgNode)
        mailTitle = self.alertEmailTitleTmpl.replace(
            '__TITLE__', "[key filter alert]" + (" ".join(msgNode)))
        mailBody = self.alertEmailBodyTmpl.replace('__BODY__',
                                                   " ".join(msgNode))

        globalVariable.totalEmailCount += 1
        toMailList = self.toEmailList['warning']
        gexingServiceMailObj = sendMail.gexingServiceMail(
            self.fromEmailInfo['fromEmail'],
            self.fromEmailInfo['fromEmailPwd'])
        gexingServiceMailObj.send(mailTitle, mailBody, toMailList)
        self.logObj.info("sendmail complete!to(" + ('.'.join(toMailList)) +
                         ")title(" + mailTitle + ")mailBody(" + mailBody + ")")
    def sendMail(self, msgNode):
        #alertData['500']['requestCount']=10
        #         ['www.gexing.com'][200]['requestCount']=5
        #
        """
print conf['msgFilter']
{'3c10c9e97fddae51e914ba17a787a57b': {'toMailList': ['*****@*****.**', '*****@*****.**'], 'serviceName': '"\xe5\xad\x98\xe5\x82\xa8', 'filterStr': ['pic.upload-server', 'fatal'], 'maxCount': '5'}, 
'50484c19f1afdaf3841a0d821ed393d2': {'toMailList': ['*****@*****.**', '*****@*****.**"'], 'serviceName': '\xe5\x85\xb6\xe5\xae\x83', 'filterStr': ['kernel'], 'maxCount': '3'}}

        """
        mailTitle = self.conf['msgFilterMail']['filtermailtmpl']
        mailBody = self.conf['msgFilterMail']['filtermailbody']
        toMailList = msgNode['toMailList']
        moduleName = msgNode['serviceName']
        mailTitle = mailTitle.replace('_MODULE_', msgNode['serviceName'])
        mailTitle = mailTitle.replace('_CNT_', str(msgNode['alertCount']))
        mailTitle = mailTitle.replace(
            '_MINUTE_',
            str(int(time.time()) - globalVariable.lastFilterAlertTime))
        tmpStr = ''
        for i in range(len(msgNode['filterStr'])):
            if (tmpStr == ''):
                tmpStr = msgNode['filterStr'][i]
            else:
                tmpStr = tmpStr + ',' + msgNode['filterStr'][i]
        dateTimeStr = time.strftime('%Y-%m-%d %H:%M:%S',
                                    time.localtime(time.time() - 2))
        mailTitle = mailTitle.replace('_STR_', tmpStr)

        mailBody = mailBody.replace('_TIME_', dateTimeStr)
        mailBody = mailBody.replace('_MODULE_', msgNode['moduleName'])
        globalVariable.totalMsgFilterEmailCount += 1

        gexingServiceMailObj = sendMail.gexingServiceMail(
            self.fromEmailInfo['fromEmail'],
            self.fromEmailInfo['fromEmailPwd'])
        gexingServiceMailObj.send(mailTitle, mailBody, toMailList)
        self.logObj.info("send msgFilter email complete!to(" +
                         ('.'.join(toMailList)) + ")title(" + mailTitle +
                         ")mailBody(" + mailBody + ")")
 def sendMailByContent(self, msgNode):
     mailTitle = self.conf['msgFilterMail']['filtermailtmpl1']
     mailTitle = mailTitle.replace('_MODULE_', msgNode['serviceName'])
     mailTitle = mailTitle.replace('_CNT_', str(msgNode['alertCount']))
     mailTitle = mailTitle.replace(
         '_MINUTE_',
         str(int(time.time()) - globalVariable.lastFilterAlertTime))
     toMailList = msgNode['toMailList']
     mailBody = msgNode['sendContent']
     tmpStr = ''
     for i in range(len(msgNode['filterStr'])):
         if (tmpStr == ''):
             tmpStr = msgNode['filterStr'][i]
         else:
             tmpStr = tmpStr + ',' + msgNode['filterStr'][i]
     mailTitle = mailTitle.replace('_STR_', tmpStr)
     globalVariable.totalMsgFilterEmailCount += 1
     gexingServiceMailObj = sendMail.gexingServiceMail(
         self.fromEmailInfo['fromEmail'],
         self.fromEmailInfo['fromEmailPwd'])
     gexingServiceMailObj.send(mailTitle, mailBody, toMailList)
     self.logObj.info("send msgFilter email by Content complete!to(" +
                      ('.'.join(toMailList)) + ")title(" + mailTitle +
                      ")mailBody(" + mailBody + ")")
    def sendMail(self, msgNode):
        #alertData['500']['requestCount']=10
        #         ['www.gexing.com'][200]['requestCount']=5
        #
        """
        错误分布\n\t时间:__TIME__,主机名:__SERVERNAME__,错误次数:__REQUESTCNT__,状态码:__STATUS__
        """
        statusList = self.conf['processPolicy']['enablestatus']
        domainList = self.conf['processPolicy']['enableservername']
        tmpStatusCountTmpl = "_STATUS_:_COUNT_"
        mailBodyList = ""
        mailTitleList = ""
        statusCountList = ""
        print msgNode
        for tmp in range(len(statusList)):

            status = statusList[tmp]
            if (int(status) != 200 and int(status) != 304):
                if (msgNode[status]['requestCount'] != 0):
                    str1 = tmpStatusCountTmpl.replace('_STATUS_', str(status))
                    str2 = str1.replace('_COUNT_',
                                        str(msgNode[status]['requestCount']))
                    statusCountList = statusCountList + "|" + str2
                tmpBodyStr = ''

                for tmp1 in range(len(domainList)):
                    domain = domainList[tmp1]
                    if (msgNode.has_key(domain)):
                        if (msgNode[domain].has_key(status)):
                            if (msgNode[domain][status]['requestCount'] != 0):
                                tmpBodyStr1 = self.alertEmailBodyTmpl
                                tmpBodyStr1 = tmpBodyStr1.replace(
                                    '__SERVERNAME__', domain)
                                tmpBodyStr1 = tmpBodyStr1.replace(
                                    '__REQUESTCOUNT__',
                                    str(msgNode[domain][status]
                                        ['requestCount']))
                                tmpBodyStr1 = tmpBodyStr1.replace(
                                    '__STATUS__', str(status))
                            else:
                                tmpBodyStr1 = ""
                            if (len(tmpBodyStr1) != 0):
                                tmpBodyStr += "<br>" + tmpBodyStr1
                            tmpBodyStr1 = ""
                        if (msgNode[domain].has_key('200')):
                            tmpStatus = '200'
                            if (msgNode[domain][tmpStatus]['requestCount'] !=
                                    0):
                                tmpBodyStr1 = self.alertEmailBodyTmpl
                                tmpBodyStr1 = tmpBodyStr1.replace(
                                    '__SERVERNAME__', domain)
                                tmpBodyStr1 = tmpBodyStr1.replace(
                                    '__REQUESTCOUNT__',
                                    str(msgNode[domain][tmpStatus]
                                        ['requestCount']))
                                tmpBodyStr1 = tmpBodyStr1.replace(
                                    '__STATUS__', str(tmpStatus))
                            else:
                                tmpBodyStr1 = ""

                            if (len(tmpBodyStr1) != 0):
                                tmpBodyStr += "<br>" + tmpBodyStr1
                            tmpBodyStr1 = ""
                        if (msgNode[domain].has_key('304')):
                            tmpStatus = '304'
                            if (msgNode[domain][tmpStatus]['requestCount'] !=
                                    0):
                                tmpBodyStr1 = self.alertEmailBodyTmpl
                                tmpBodyStr1 = tmpBodyStr1.replace(
                                    '__SERVERNAME__', domain)
                                tmpBodyStr1 = tmpBodyStr1.replace(
                                    '__REQUESTCOUNT__',
                                    str(msgNode[domain][tmpStatus]
                                        ['requestCount']))
                                tmpBodyStr1 = tmpBodyStr1.replace(
                                    '__STATUS__', str(tmpStatus))
                            else:
                                tmpBodyStr1 = ""

                            if (len(tmpBodyStr1) != 0):
                                tmpBodyStr += "<br>" + tmpBodyStr1

                            tmpBodyStr1 = ""

                        tmpBodyStr = tmpBodyStr.replace('__DOMAIN__', domain)
                if (len(tmpBodyStr) != 0):
                    mailBodyList = mailBodyList + tmpBodyStr + "<br><br>"
                    tmpBodyStr = ""
                else:
                    self.logObj.info("this status has 0 error msg!")

        if (len(mailBodyList) != 0):
            dateTimeStr = time.strftime('%Y-%m-%d %H:%M:%S',
                                        time.localtime(time.time() - 2))
            mailBodyList = mailBodyList.replace('__TIME__', dateTimeStr)
            mailBodyList = "时间:" + dateTimeStr + "  " + mailBodyList
            mailTitleList = self.alertEmailTitleTmpl.replace(
                '__STATUSCOUNT__', statusCountList)
            diffStrTime = str(int(time.time()) - globalVariable.lastAlertTime)
            mailTitleList = mailTitleList.replace('_MINUTE_', diffStrTime)
            globalVariable.totalEmailCount += 1
            toMailList = self.toEmailList['warning']
            gexingServiceMailObj = sendMail.gexingServiceMail(
                self.fromEmailInfo['fromEmail'],
                self.fromEmailInfo['fromEmailPwd'])
            gexingServiceMailObj.send(mailTitleList, mailBodyList, toMailList)
            self.logObj.info("send email complete!to(" +
                             ('.'.join(toMailList)) + ")title(" +
                             mailTitleList + ")mailBody(" + mailBodyList + ")")
        else:
            self.logObj.info("this status has 0 error msg!")
Example #9
0
    def sendMail( self, msgNode ):
        #alertData['500']['requestCount']=10
        #         ['www.gexing.com'][200]['requestCount']=5
        #
        """
        错误分布\n\t时间:__TIME__,主机名:__SERVERNAME__,错误次数:__REQUESTCNT__,状态码:__STATUS__
        """
        statusList = self.conf['processPolicy']['enablestatus']
        domainList = self.conf['processPolicy']['enableservername']
	tmpStatusCountTmpl = "_STATUS_:_COUNT_"
	mailBodyList =""
	mailTitleList=""
	statusCountList=""
	print msgNode
        for tmp in range( len( statusList ) ):

            status = statusList[tmp]
            if ( int(status) != 200 and int(status) !=304 ):
		if ( msgNode[status]['requestCount'] != 0 ):
			str1 = tmpStatusCountTmpl.replace('_STATUS_', str(status) )	
			str2 = str1.replace('_COUNT_', str(msgNode[status]['requestCount']))
			statusCountList = statusCountList + "|"+str2
                tmpBodyStr = ''

                for tmp1 in range( len(domainList)):
                    domain = domainList[tmp1]
                    if ( msgNode.has_key(domain) ):
                        if (msgNode[domain].has_key(status)):
                            if ( msgNode[domain][status]['requestCount'] != 0 ):
                                            tmpBodyStr1 = self.alertEmailBodyTmpl
                                            tmpBodyStr1 = tmpBodyStr1.replace('__SERVERNAME__', domain )
                                            tmpBodyStr1 = tmpBodyStr1.replace('__REQUESTCOUNT__', str(msgNode[domain][status]['requestCount']) )
                                            tmpBodyStr1 = tmpBodyStr1.replace('__STATUS__', str(status) )
                            else:
                                tmpBodyStr1 = ""
			    if ( len( tmpBodyStr1 ) != 0 ):
                            	tmpBodyStr += "<br>"+tmpBodyStr1
			    tmpBodyStr1 = ""
                        if ( msgNode[domain].has_key('200') ):
                            tmpStatus = '200'
                            if ( msgNode[domain][tmpStatus]['requestCount'] != 0 ):
                                            tmpBodyStr1 = self.alertEmailBodyTmpl
                                            tmpBodyStr1 = tmpBodyStr1.replace('__SERVERNAME__', domain )
                                            tmpBodyStr1 = tmpBodyStr1.replace('__REQUESTCOUNT__', str(msgNode[domain][tmpStatus]['requestCount']) )
                                            tmpBodyStr1 = tmpBodyStr1.replace('__STATUS__', str(tmpStatus) )
                            else:
                                tmpBodyStr1 = ""

			    if ( len( tmpBodyStr1 ) != 0 ):
                            	tmpBodyStr += "<br>"+tmpBodyStr1
			    tmpBodyStr1 = ""
                        if ( msgNode[domain].has_key('304') ):
                            tmpStatus = '304'
                            if ( msgNode[domain][tmpStatus]['requestCount'] != 0 ):
                                            tmpBodyStr1 = self.alertEmailBodyTmpl
                                            tmpBodyStr1 = tmpBodyStr1.replace('__SERVERNAME__', domain )
                                            tmpBodyStr1 = tmpBodyStr1.replace('__REQUESTCOUNT__', str(msgNode[domain][tmpStatus]['requestCount']) )
                                            tmpBodyStr1 = tmpBodyStr1.replace('__STATUS__', str(tmpStatus) )
                            else:
                                tmpBodyStr1 = ""

			    if ( len( tmpBodyStr1 ) != 0 ):
                            	tmpBodyStr += "<br>"+tmpBodyStr1

			    tmpBodyStr1 = ""

                        tmpBodyStr = tmpBodyStr.replace( '__DOMAIN__', domain )
                if ( len( tmpBodyStr ) != 0 ):
			mailBodyList = mailBodyList+ tmpBodyStr+"<br><br>"
			tmpBodyStr = ""
		else:
                	self.logObj.info( "this status has 0 error msg!" )

	if ( len( mailBodyList ) != 0 ):
                dateTimeStr = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()-2))
		mailBodyList = mailBodyList.replace( '__TIME__', dateTimeStr )
		mailBodyList = "时间:"+dateTimeStr+"  "+mailBodyList
		mailTitleList =  self.alertEmailTitleTmpl.replace( '__STATUSCOUNT__',  statusCountList)
		diffStrTime = str(int(time.time())- globalVariable.lastAlertTime)
		mailTitleList =  mailTitleList.replace( '_MINUTE_',  diffStrTime)
                globalVariable.totalEmailCount += 1
                toMailList = self.toEmailList[ 'warning' ]
                gexingServiceMailObj =  sendMail.gexingServiceMail( self.fromEmailInfo[ 'fromEmail' ] , self.fromEmailInfo[ 'fromEmailPwd' ] )
                gexingServiceMailObj.send( mailTitleList, mailBodyList, toMailList )
                self.logObj.info( "send email complete!to("+( '.'.join( toMailList ) )+")title("+mailTitleList+")mailBody("+mailBodyList+")" )
        else:
        	self.logObj.info( "this status has 0 error msg!" )