db_user = 'root'
db_pwd = '123457'
db_host = '10.1.163.33'
db_database = 'shareMM'
if __name__ == '__main__':
#version
vDate = datetime.datetime.now() + datetime.timedelta(days=-1)
vDateStr = vDate.strftime('%y-%m-%d')
MhoVersion = 'MHFC_DevMain_%s'%(vDateStr) #1
dReport = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') #2
trDatas = []
conn=pymysql.connect(host=db_host,user=db_user,passwd=db_pwd,db=db_database,port=3309,charset='utf8')
cur = conn.cursor()
cur.execute('select * from townsvr_mem where info_time="2014-10-21"')
dTownMem=cur.fetchall()
cur.execute('select * from townsvr_cpu where info_time="2014-10-21"')
dTownCpu=cur.fetchall()
cur.execute('select * from townsvr_fps where info_time="2014-10-21"')
dTownFps=cur.fetchall()
cur.execute('select * from worldsvr_mem where info_time="2014-10-21"')
dWorldMem=cur.fetchall()
cur.execute('select * from worldsvr_cpu where info_time="2014-10-21"')
dWorldCpu=cur.fetchall()
cur.execute('select * from worldsvr_fps where info_time="2014-10-21"')
dWorldFps=cur.fetchall()
tmpList = []
tmpList.append('350人城镇随机行走')
tmpList.append('townsvr')
fmem = int(dTownMem[0][5]) / 1000
strmem = '%.2f M'%(fmem)
tmpList.append(strmem)
fmem = int(dTownMem[0][3]) / 1000
strmem = '%.2f M'%(fmem)
tmpList.append(strmem)
tmpList.append(dTownFps[0][5])
tmpList.append(dTownFps[0][3])
tmpList.append(dTownCpu[0][5])
tmpList.append(dTownCpu[0][3])
trDatas.append(tmpList)
tmpList = []
tmpList.append('350人城镇随机行走')
tmpList.append('worldsvr')
fmem = int(dWorldMem[0][5]) / 1000
strmem = '%.2f M'%(fmem)
tmpList.append(strmem)
fmem = int(dWorldMem[0][3]) / 1000
strmem = '%.2f M'%(fmem)
tmpList.append(strmem)
tmpList.append(dWorldFps[0][5])
tmpList.append(dWorldFps[0][3])
tmpList.append(dWorldCpu[0][5])
tmpList.append(dWorldCpu[0][3])
trDatas.append(tmpList)
tblStr = ''
for ii in range(len(trDatas)):
tblStr = tblStr + fillSvrTableTR(trDatas[ii],8) #3
dtime = datetime.datetime.now().strftime('%y-%m-%d')
#456
svrMemSrc = 'http://10.1.163.33:8180/MHOProject/mhoperformance/chart/%s/townworldmem.png'%(dtime)
svrFpsSrc = 'http://10.1.163.33:8180/MHOProject/mhoperformance/chart/%s/townworldfps.png'%(dtime)
svrCpuSrc = 'http://10.1.163.33:8180/MHOProject/mhoperformance/chart/%s/townworldcpu.png'%(dtime)
print(svrMemSrc)
html = reportStr.html_content%(MhoVersion,dReport,tblStr,svrMemSrc,svrFpsSrc,svrFpsSrc)
# print(html)
# bb = html.decode('gb2312').encode('utf-8')
f = codecs.open('%s.html'%(dtime),'w','utf-8')
f.write(html)
f.close()
# mail info
smtpsvr = ('tsmtp.tencent.com')#('172.25.7.178')
From = "
deepmao@tencent.com"
To = ["
deepmao@tencent.com"]
Subject = "怪物猎人服务器常态化性能测试"
main_msg = MIMEMultipart()
main_msg['From'] = From
main_msg['To'] = ";".join(To)
main_msg['Subject'] = "%s"%(Subject)
main_msg['Date'] = email.utils.formatdate()
# 发送文本邮件
# htmlText = 'just python text mail test'
# text_msg = MIMEText("%s"%htmlText,_subtype='html',_charset='utf-8')
# main_msg.attach(text_msg)
# 发送html邮件
# msgText = MIMEText(html,'html','utf-8')
# main_msg.attach(msgText)
# smtp = smtplib.SMTP()
# smtp.connect(smtpsvr)
# smtp.login('deepmao', 'am0443AMM')
# smtp.sendmail(From, To, main_msg.as_string(unixfrom=True))
# smtp.quit()
# sendMail(smtpsvr,From,To,Subject,htmlText,'html')