LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   How to modify the zabbix script? (https://www.linuxquestions.org/questions/linux-server-73/how-to-modify-the-zabbix-script-4175559502/)

624867243@qq.com 11-21-2015 06:59 AM

How to modify the zabbix script?
 
I use zabbix as a monitor, but i have a problem, when the zabbix send Alarm email,then the email would send by SMS to my iphone. If the email title is Japanese or Chinese. the sms is Disorder Code. Here is the scripts,how to modify it?

Code:

#!/usr/bin/python26
#coding:utf-8
import smtplib
from email.mime.text import MIMEText
import sys
mail_host = 'smtp.189.cn'
mail_user = 'Tom_a'
mail_pass = '123456'
mail_postfix = '189.cn'
def send_mail(to_list,subject,content):
  me = mail_user+"<"+mail_user+"@"+mail_postfix+">"
  msg = MIMEText(content,_subtype='plain',_charset='utf-8')
  msg['Subject'] = subject
  msg['From'] = me
  msg['to'] = 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
if __name__ == "__main__":
  send_mail(sys.argv[1], sys.argv[2], sys.argv[3])


624867243@qq.com 11-22-2015 10:33 AM

No one know how to modify?

morrolan 11-24-2015 08:58 AM

Hey, long time Zabbix admin and python dev here. In order to help you, I would like to ask a few questions:
  • Are you using the default Media types in Zabbix?
  • What SMS provider are you using, and how have you incorporated it into Zabbix (custom scripts etc)?
  • Just to clarify what you mean, when Zabbix triggers a particular category/trigger, it sends an email. Does it send the SMS via the same Alert, or is the SMS configured independently?
  • I am unsure what you mean by " If the email title is Japanese or Chinese. the sms is Disorder Code." - please can you elaborate? Do you mean that if the email title is in Japanese or Chinese then it produces some kind of error?

Many thanks!

624867243@qq.com 11-25-2015 10:25 AM

(1)I have used the default Media types in Zabbix.
(2)but i use emali,then email would send to my iphone,because it is free,189 mail or 139 mail has a free fucnction,so i want to send email,then the email woul send to my iphone autolly.
(3) it send the email not by SMS.
(4)the title contains Visible name and the Visible name is Chinese. it is Disorder Code,I think it had nothing to do with zabbix;
for example,I use a test mail,
python sendmail.py knight@189.cn "北方" "正文", then my 189 mailbox have recived,then the mail would send infomation to my ipone autoly and freely.
but my iphone show the title is Disorder Code,and the body is normal.



Quote:

Originally Posted by morrolan (Post 5454542)
Hey, long time Zabbix admin and python dev here. In order to help you, I would like to ask a few questions:
  • Are you using the default Media types in Zabbix?
  • What SMS provider are you using, and how have you incorporated it into Zabbix (custom scripts etc)?
  • Just to clarify what you mean, when Zabbix triggers a particular category/trigger, it sends an email. Does it send the SMS via the same Alert, or is the SMS configured independently?
  • I am unsure what you mean by " If the email title is Japanese or Chinese. the sms is Disorder Code." - please can you elaborate? Do you mean that if the email title is in Japanese or Chinese then it produces some kind of error?

Many thanks!



All times are GMT -5. The time now is 11:27 AM.