A value of the monitoring URL is less than the specified value-mail alarm
#!/usr/bin/env python#-*-coding:utf-8-*-__author__='Liudong'ImportUrllib,sys,urllib,json,smtplib fromEmail.mime.textImportmimetextmailto_list=['[email protected]']mail_host="smtp.exmail.qq.com"Mail_user="[email protected]"Mail_pass="abcABC123"Mail_postfix="researchina.cn"defSend_mail (to_list,sub,content): Me="Hello"+"<"+mail_user+"@"+mail_postfix+">"msg= Mimetext (content,_subtype='Plain') msg['Subject'] =Sub msg[' from'] =Me msg[' to'] =";". Join (to_list)Try: Server= Smtplib. SMTP (mail_host,25) Server.set_debuglevel (1) Server.login (Mail_user,mail_pass) Server.sendmail (Me, To_list, msg.as_string ()) Server.close () except : returnFalseurl="http://storm.yqing.cn/api/v1/cluster/summary"WP=urllib.urlopen (URL). Read ()#content = Wp.read ()#Print (WP)A =json.loads (WP) b= (a["Supervisors"]) #print (b)ifB < 3: Send_mail (mailto_list,'Storm UI','Please check immediately error')
Python implements a value for the monitoring URL that is less than the specified value-mail alerts