zeeeitch 发表于 2013-1-15 02:34:10

服务器温度检测邮件脚本

import stringimport os import smtplibfrom email.mime.text import MIMETextdef send_mail(to_list,sub,content):    me=mail_user+"<"+mail_user+"@"+mail_postfix+">"    msg = MIMEText(content)    msg['Subject'] = sub    msg['From'] = me    msg['To'] = ";".join(to_list)    try:      s = smtplib.SMTP()      s.connect(mail_host)      s.login(mail_user,mail_pass)      s.sendmail(me, to_list, msg.as_string())      s.close()      return True    except Exception, e:      print str(e)      return False      (si, so, se) = os.popen3('k8temp') t=so.readlines() for line in t:if len(line)>22:ifstring.atoi(line)>47:#print string.atoi(line)mailto_list=["zhanghao1979@gmail.com"]mail_host="smtp.163.com"mail_user="zeeeitch"mail_pass="do not say out"mail_postfix="163.com"if not send_mail(mailto_list,"237.11 temperature problem",line):    print "send err"
页: [1]
查看完整版本: 服务器温度检测邮件脚本