Tag:head effect app pos 3.2 ext print install water
I. Overview and environmental requirements 1, overview Zabbix Monitoring also plays an important role, the following is the use of Python script to send alert mail configuration method. Previously used SendEmail mail alarm but found that the subject of the message will be garbled when the Chinese language. 2, Environment installation requirements Zabbix software version: zabbix3.2.6 operating system: CentOS release 6.8 (Final) II, script creation and testing 1, view configuration zabbix_server.conf, find Alertscriptspath , view the path location, such as comments, open the note, and save the send.py file to the directory. Grep-n ' ^[a-z] '/usr/local/etc/zabbix_server.conf38:logfile=/tmp/zabbix_server.log87:dbname=zabbix103:dbuser= zabbix111:dbpassword=zabbix126:dbport=3306239:startvmwarecollectors=10247:vmwarefrequency=60255: vmwareperffrequency=60265:vmwarecachesize=80m273:vmwaretimeout=10281:snmptrapperfile=/tmp/zabbix_traps.tmp289: startsnmptrapper=0407:timeout=4448:alertscriptspath=/usr/local/share/zabbix/alertscripts492:logslowqueries= 30002, if there is modification configuration, you need to restart the Zabbix-server service. /etc/init.d/zabbix_server Restart3, enter Zabbix e-mail script directory cd/usr/local/share/zabbix/alertscripts4, create scripts and configure Vim Zabbix-mail.py #!/usr/bin/python #coding: utf-8 import smtplib from email.mime.text Import Mimetext import sys mail_host = ' smtp.qq.com ' mail_user = ' 10880347 ' mail_pass = ' ********** ' mail_postfix = ' qq.com ' def send_mail (to_list,subject,content): & nbsp; me = "zabbix3.2 Monitoring alarm Platform" + "<" +mail_user+ "@" +mail_postfix+ ">" msg = Mimetext ( Content, ' plain ', ' 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_mai L (Sys.argv[1], sys.argv[2], sys.argv[3]) 5. Add Executable permissions chmod +X zabbix-mail.pychown-r Zabbix.zabbix zabbix-mail.py 6. Test mail Python zabbix-mail.py [email protected] Test Test
Third, Zabbix server alarm Media Type 1, Web interface settings http://172.16.8.200/zabbix/Add three parameters {ALERT. SENDTO} recipient address {ALERT. SUBJECT} subject {ALERT. MESSAGE} Detailed content
2. Create an alarm user
3. Configure the Alarm media
4. Configure permissions now test the environment so configure Super Admin permissions, if the production environment is recommended to use user rights
Iv. Configuring Alarm Action 1, creating a new trigger action
2. Configure the action
3, configuration operation failure {TRIGGER. STATUS}, server: {HOSTNAME1} occurred: {trigger.name} failed! Alarm host: {HOSTNAME1} alarm time: {EVENT. DATE} {EVENT. TIME} Alarm level: {TRIGGER. SEVERITY} Alarm message: {trigger.name} alarm item: {TRIGGER. KEY1} Problem Details: {item.name}:{item. VALUE} current status: {TRIGGER. Status}:{item. VALUE1} Event Id:{event.id}
4, configure recovery operation recovery {TRIGGER. STATUS}, server: {HOSTNAME1}: {trigger.name} restored! Alarm host: {HOSTNAME1} alarm time: {EVENT. DATE} {EVENT. TIME} Alarm level: {TRIGGER. SEVERITY} Alarm message: {trigger.name} alarm item: {TRIGGER. KEY1} Problem Details: {item.name}:{item. VALUE} current status: {TRIGGER. Status}:{item. VALUE1} Event Id:{event.id}
5. Email Alarm test Results
The e-mail script is optimized to solve the problem that Outlook receive headers are garbled.
#!/usr/bin/python #coding: utf-8 import smtplib from email.header Import Header from Email.mime.text import mimetext import sys mail_host = ' mail.qq.com ' mail_user = ' 10880347 '   ; mail_pass = ' ******** ' mail_postfix = ' qq.com ' def send_mail (to_list,subject,content): #me = "XXX company Zabbix Monitoring alarm" + "<" +mail_user+ "@" +mail_postfix+ ">" me = ("%s<[email Protected]> ")% (Header (' xxx company zabbix_ monitor alarm! ', ' utf-8 '),) msg = mimetext (content, ' plain ', ' Utf-8 ') & nbsp; msg[' Subject '] = Subject msg[' from '] = Me msg["to"] = to_list & nbsp; 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__": SE Nd_mail (Sys.argv[1], sys.argv[2], sys.argv[3])
Zabbix3.2 Mail Alert python script