def sendCloseMail(content, repo, receivers, CloseDay): mail = Mail() mail.set_sender('*****@*****.**') mail.set_receivers(receivers) mail.set_title('%s repo关闭超过%s天未更新的issue/pr通知' % (repo, CloseDay)) mail.set_message(content, messageType='html', encoding='gb2312') mail.send()
def sendMonitorMail(content): mail = Mail() mail.set_sender('*****@*****.**') mail.set_receivers(['*****@*****.**']) mail.set_title('gitClone时间超过10min!') mail.set_message(content, messageType='html', encoding='gb2312') mail.send()
def mail(HTML_CONTENT): mail = Mail() mail.set_sender('*****@*****.**') mail.set_receivers(['*****@*****.**']) mail.set_title("【告警】效率云过去4小时/过去1天CI指标") mail.set_message(HTML_CONTENT, messageType='html', encoding='gb2312') mail.send()
def sendCloseMail(content): mail = Mail() mail.set_sender('*****@*****.**') mail.set_receivers(['*****@*****.**']) mail.set_title('关闭超过1年未更新的issue/pr通知~') mail.set_message(content, messageType='html', encoding='gb2312') mail.send()
def sendMail(self, mailContent): HTML_CONTENT = "<html><body><p>Hi, ALL:</p>" HTML_CONTENT += mailContent HTML_CONTENT += "<p>如有问题,请联系张春乐.</p> <p>张春乐</p></body></html>" mail = Mail() mail.set_sender('*****@*****.**') mail.set_receivers(['*****@*****.**']) mail.set_title('[告警]自动取消超时任务') mail.set_message(HTML_CONTENT, messageType='html', encoding='gb2312') mail.send()
def sendMail(self, mailContent): """ this function will send alarm mail. """ mail = Mail() mail.set_sender('*****@*****.**') mail.set_receivers(['*****@*****.**']) mail.set_title('[告警]任务等待超时') mail.set_message(mailContent, messageType='html', encoding='gb2312') mail.send()
def sendMail(ciIndex_thisWeek, ciIndex_lastWeek=0): thisWeekCommit = ciIndex_thisWeek['commitCount'] lastWeekCommit = ciIndex_lastWeek[ 'commitCount'] if ciIndex_lastWeek != 0 else 0 COMMIT_AND_TIME = "<table border='1' align=center> <caption><font size='3'><b>用户感知指标</b></font></caption>" if ciIndex_lastWeek == 0: DIFF_RATE = "%.2f" % float((thisWeekCommit - 0.00001) / 0.00001 * 100) else: DIFF_RATE = "%.2f" % float( abs(thisWeekCommit - lastWeekCommit) / lastWeekCommit * 100) if thisWeekCommit - lastWeekCommit > 0: COMMIT_AND_TIME += "<tr align=center><td bgcolor='#d0d0d0'>commit数</td><td bgcolor='#ff6eb4'>%s(↑ %s" % ( thisWeekCommit, DIFF_RATE) COMMIT_AND_TIME += "%)</td></tr>" else: COMMIT_AND_TIME += "<tr align=center><td bgcolor='#d0d0d0'>commit数</td><td bgcolor='#b5c4b1'>%s(↓ %s" % ( thisWeekCommit, DIFF_RATE) COMMIT_AND_TIME += "%)</td></tr>" MAX_WAITTIME = max( float(ciIndex_thisWeek['PR-CI-Coverage_average_wait_time']), float(ciIndex_thisWeek['PR-CI-Py35_average_wait_time']), float(ciIndex_thisWeek['PR-CI-Inference_average_wait_time']), float(ciIndex_thisWeek['PR-CI-CPU-Py2_average_wait_time'])) MAX_EXECTIME = max( float(ciIndex_thisWeek['PR-CI-Coverage_average_exec_time']), float(ciIndex_thisWeek['PR-CI-Py35_average_exec_time']), float(ciIndex_thisWeek['PR-CI-Inference_average_exec_time']), float(ciIndex_thisWeek['PR-CI-CPU-Py2_average_exec_time'])) COMMIT_AND_TIME += "<tr align=center><td bgcolor='#d0d0d0'>commit从提交到返回结果耗时</td><td>%.2f min</td></tr>" % ( MAX_WAITTIME + MAX_EXECTIME) COMMIT_AND_TIME += "</table>" HTML_CONTENT = "<html><body><p>Hi, ALL:</p> <p>本周CI评价指标详细信息可参考如下表格:</p> %s" % COMMIT_AND_TIME HTML_TABLE_CONTENT = write_excel_xls(ciIndex_thisWeek, ciIndex_lastWeek) HTML_CONTENT = HTML_CONTENT + "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td height='10'></td</tr></table>" + HTML_TABLE_CONTENT + "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td height='10'></td</tr></table>" + "<p>如有问题,随时联系</p> <p>张春乐</p></body></html>" mail = Mail() mail.set_sender('*****@*****.**') mail.set_receivers(['*****@*****.**']) mail.set_title( '效率云%s~%s CI评价指标统计' % (ciIndex_thisWeek['startTime'], ciIndex_thisWeek['endTime'])) mail.set_message(HTML_CONTENT, messageType='html', encoding='gb2312') mail.send()
def sendMail(ciIndex_thisWeek, ciIndex_lastWeek=0): COMMIT_AND_TIME = "<table border='1' align=center> <caption><font size='3'><b>用户感知指标</b></font></caption>" repo_list = localConfig.cf.get('ciIndex', 'commitCount').split(',') #用户感知指标: 各个repo的commit的数目 for repo in repo_list: key = '%s_commitCount' % repo.split('/')[1] thisWeekCommit = ciIndex_thisWeek[key] lastWeekCommit = ciIndex_lastWeek[key] if ciIndex_lastWeek != 0 else 0 if ciIndex_lastWeek == 0: DIFF_RATE = "%.2f" % float( (thisWeekCommit - 0.00001) / 0.00001 * 100) else: DIFF_RATE = "%.2f" % float( abs(thisWeekCommit - lastWeekCommit) / lastWeekCommit * 100) if thisWeekCommit - lastWeekCommit > 0: COMMIT_AND_TIME += "<tr align=center><td bgcolor='#d0d0d0'>%s commit数/个</td><td bgcolor='#ff6eb4'>%s(↑ %s" % ( repo.split('/')[1], thisWeekCommit, DIFF_RATE) COMMIT_AND_TIME += "%)</td></tr>" else: COMMIT_AND_TIME += "<tr align=center><td bgcolor='#d0d0d0'>%s commit数/个</td><td bgcolor='#b5c4b1'>%s(↓ %s" % ( repo.split('/')[1], thisWeekCommit, DIFF_RATE) COMMIT_AND_TIME += "%)</td></tr>" #用户感知指标: commit从提交到返回结果平均耗时 thisweek_MAX_CONSUMTIME = 0 CI_NAME_list = localConfig.cf.get('ciIndex', 'ci_name').split(',') #所有的ci for ci in CI_NAME_list: if float(ciIndex_thisWeek['%s_average_consum_time' % ci]) > thisweek_MAX_CONSUMTIME: thisweek_MAX_CONSUMTIME = float( ciIndex_thisWeek['%s_average_consum_time' % ci]) max_CONSUMTIME_CI = ci lastweek_MAX_CONSUMTIME = float(ciIndex_lastWeek['%s_average_consum_time' % max_CONSUMTIME_CI]) consum_DIFF_RATE = "%.2f" % float( abs(thisweek_MAX_CONSUMTIME - lastweek_MAX_CONSUMTIME) / lastweek_MAX_CONSUMTIME * 100) if thisweek_MAX_CONSUMTIME - lastweek_MAX_CONSUMTIME > 0: COMMIT_AND_TIME += "<tr align=center><td bgcolor='#d0d0d0'>commit从提交到返回结果平均耗时/min</td><td bgcolor='#ff6eb4'>%s(↑ %s" % ( thisweek_MAX_CONSUMTIME, consum_DIFF_RATE) COMMIT_AND_TIME += "%)</td></tr>" else: COMMIT_AND_TIME += "<tr align=center><td bgcolor='#d0d0d0'>commit从提交到返回结果平均耗时/min</td><td bgcolor='#b5c4b1'>%s(↓ %s" % ( thisweek_MAX_CONSUMTIME, consum_DIFF_RATE) COMMIT_AND_TIME += "%)</td></tr>" #用户感知指标: commit从提交到返回结果最长耗时 thisweek_Longest_Time = float(ciIndex_thisWeek['LongestTime']) lastweek_Longest_Time = float(ciIndex_lastWeek['LongestTime']) longestTime_DIFF_RATE = "%.2f" % float( abs(thisweek_Longest_Time - lastweek_Longest_Time) / lastweek_Longest_Time * 100) if thisweek_Longest_Time - lastweek_Longest_Time > 0: COMMIT_AND_TIME += "<tr align=center><td bgcolor='#d0d0d0'>commit从提交到返回结果最长耗时/min</td><td bgcolor='#ff6eb4'>%s(↑ %s" % ( thisweek_Longest_Time, longestTime_DIFF_RATE) COMMIT_AND_TIME += "%)</td></tr>" else: COMMIT_AND_TIME += "<tr align=center><td bgcolor='#d0d0d0'>commit从提交到返回结果最长耗时/min</td><td bgcolor='#b5c4b1'>%s(↓ %s" % ( thisweek_Longest_Time, longestTime_DIFF_RATE) COMMIT_AND_TIME += "%)</td></tr>" #用户感知指标: 单测随机挂引起的RERUN占比 thisWeek_rerun_index = testRerun( '%s 00:00:00' % ciIndex_thisWeek['startTime'], '%s 00:00:00' % ciIndex_thisWeek['endTime']) lastWeek_rerun_index = testRerun( '%s 00:00:00' % ciIndex_lastWeek['startTime'], '%s 00:00:00' % ciIndex_lastWeek['endTime']) rerun_DIFF_RATE = "%.2f" % float( abs( float(thisWeek_rerun_index['all_testfailed_rerunRatio']) - float(lastWeek_rerun_index['all_testfailed_rerunRatio']))) if float(thisWeek_rerun_index['all_testfailed_rerunRatio']) - float( lastWeek_rerun_index['all_testfailed_rerunRatio']) > 0: COMMIT_AND_TIME += "<tr align=center><td bgcolor='#d0d0d0'>单测随机挂引起的RERUN占比</td>" RERUN_INDEX_DIFF = "<td bgcolor='#ff6eb4'>%s" % thisWeek_rerun_index[ 'all_testfailed_rerunRatio'] + "%(↑ " + "%s" % rerun_DIFF_RATE + "%)</td>" else: COMMIT_AND_TIME += "<tr align=center><td bgcolor='#d0d0d0'>单测随机挂引起的RERUN占比</td>" RERUN_INDEX_DIFF = "<td bgcolor='#b5c4b1'>%s" % thisWeek_rerun_index[ 'all_testfailed_rerunRatio'] + "%(↓ " + "%s" % rerun_DIFF_RATE + "%)</td>" COMMIT_AND_TIME += RERUN_INDEX_DIFF COMMIT_AND_TIME += "</tr>" #用户感知指标: 平均失败率最大的CI及大小 thisweek_MAX_FAILEDRATE = 0 for ci in CI_NAME_list: if float(ciIndex_thisWeek['%s_failRate' % ci]) > thisweek_MAX_FAILEDRATE: thisweek_MAX_FAILEDRATE = float(ciIndex_thisWeek['%s_failRate' % ci]) max_FAILEDRATE_CI = ci lastweek_MAX_FAILEDRATE = float(ciIndex_lastWeek['%s_failRate' % max_FAILEDRATE_CI]) failed_DIFF_RATE = "%.2f" % float( abs(float(thisweek_MAX_FAILEDRATE) - float(lastweek_MAX_FAILEDRATE)) * 100) if float(thisweek_MAX_FAILEDRATE) - float(lastweek_MAX_FAILEDRATE) > 0: COMMIT_AND_TIME += "<tr align=center><td bgcolor='#d0d0d0'>平均失败率最大的CI及大小</td>" FAILED_INDEX_DIFF = "<td bgcolor='#ff6eb4'>%s: %.2f" % ( max_FAILEDRATE_CI, thisweek_MAX_FAILEDRATE * 100) + "%(↑ " + "%s" % failed_DIFF_RATE + "%)</td>" else: COMMIT_AND_TIME += "<tr align=center><td bgcolor='#d0d0d0'>平均失败率最大的CI及大小</td>" FAILED_INDEX_DIFF = "<td bgcolor='#b5c4b1'>%s: %.2f" % ( max_FAILEDRATE_CI, thisweek_MAX_FAILEDRATE * 100) + "%(↓ " + "%s" % failed_DIFF_RATE + "%)</td>" COMMIT_AND_TIME += FAILED_INDEX_DIFF COMMIT_AND_TIME += "</tr></table>" #效率云CI由于单测随机挂RERUN占比 thisWeek_RERUN_TABLE = "<table border='1' align=center> <caption><font size='3'><b>效率云CI由于单测随机挂RERUN占比</b></font></caption>" thisWeek_RERUN_TABLE += "<tr align=center><td bgcolor='#d0d0d0'>CI名称</td><td>整体</td><td>PR-CI-Coverage</td><td> PR-CI-Py3</td><td>PR-CI-Mac</td><td>PR-CI-Mac-Python3</td><td>PR-CI-Windows</td>" thisWeek_RERUN_TABLE += "</tr><tr align=center><td bgcolor='#d0d0d0'>单测随机挂引起的Rerun</td><td>%s" % thisWeek_rerun_index[ 'all_testfailed_rerunRatio'] thisWeek_RERUN_TABLE += "%</td>" rerun_ci_by_utfail_list = localConfig.cf.get( 'ciIndex', 'rerun_ci_by_utfail').split(',') for ci in rerun_ci_by_utfail_list: thisWeek_RERUN_TABLE += "<td>{}%</td>".format( thisWeek_rerun_index['%s_testfailed_rerunRatio' % ci]) thisWeek_RERUN_TABLE += "</tr></table>" #失败原因占比 EXCODE_TABLE = excode('%s 00:00:00' % ciIndex_thisWeek['startTime'], '%s 00:00:00' % ciIndex_thisWeek['endTime']) #对内关键指标与对内详细指标 KEY_CI_INDEX_TABLE, DETAIL_CI_INDEX_TABLE = get_key_detail_ci_index( ciIndex_thisWeek, ciIndex_lastWeek) #汇总表格 HTML_CONTENT = "<html><body><p>Hi, ALL:</p> <p>本周(%s 00:00:00 ~ %s 00:00:00)CI评价指标详细信息可参考如下表格:</p> <p>CI评价指标的计算方式可见: http://agroup.baidu.com/paddle-ci/md/article/3352500</p><p>现在机器资源如下: V100(coverage/py3) 17台, P4(Inference/CPU) 4台, Mac 8台, Windows 15台</p> %s" % ( ciIndex_thisWeek['startTime'], ciIndex_thisWeek['endTime'], COMMIT_AND_TIME) HTML_CONTENT = HTML_CONTENT + "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td height='10'></td</tr></table>" \ + KEY_CI_INDEX_TABLE + "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td height='10'></td</tr></table>" \ + thisWeek_RERUN_TABLE + "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td height='10'></td</tr></table>" \ + EXCODE_TABLE + "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td height='10'></td</tr></table>"\ + DETAIL_CI_INDEX_TABLE + "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td height='10'></td</tr></table>" \ + "<p>如有问题,请反馈到CE and CI值班群(xxx)或联系张春乐.</p> <p>张春乐</p></body></html>" mail = Mail() mail.set_sender('xxxx') mail.set_receivers(['*****@*****.**']) mail.set_title( '效率云%s~%s CI评价指标统计' % (ciIndex_thisWeek['startTime'], ciIndex_thisWeek['endTime'])) mail.set_message(HTML_CONTENT, messageType='html', encoding='gb2312') mail.send()