1. How to add Zabbix: Manage -- Solution -- create media type
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/122H0C46-0.png "border =" 0 "alt =" "/>
Zabbix sends three parameters to the script: recipient, subject, and content.
Zabbix_sendmail.py
- #!/usr/bin/python
- #coding:utf-8
-
-
- import smtplib
- from email.mime.text import MIMEText
- import sys
-
- mail_host = 'smtp.163.com'
- mail_user = 'username'
- mail_pass = 'password'
- mail_postfix = '163.com'
-
- def send_mail(to_list,subject,content):
- me = mail_user+"<"+mail_user+"@"+mail_postfix+">"
- msg = MIMEText(content)
- 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])
2. Add trigger settings: System Configuration-operation-create action
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/122H062Y-1.png "border =" 0 "alt =" "/>
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/122H0C53-2.png "border =" 0 "alt =" "/>
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/122H04193-3.png "border =" 0 "alt =" "/>
3. Add the script configuration to zabbix_server:
Mkdir-p/usr/local/zabbix/scripts
Upload the script to this directory.
Modify zabbix_server.conf:
AlertScriptsPath =/usr/local/zabbix/scripts
Then restart the service.
The configuration is complete. It's easy !~
This article is from the "O & M notes" blog, please be sure to keep this source http://lihuipeng.blog.51cto.com/3064864/1066915