In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces zabbix how to use python script to send alarm email related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that after reading this zabbix how to use python script to send alarm email article will have a harvest, let's take a look.
The steps are as follows:
1. Edit the zabbix_server.conf file and modify the alertscriptspath parameter, which is used to specify the absolute path of the external script.
Vim / etc/zabbix/zabbix_server.confalertscriptspath=/usr/lib/zabbix/alertscripts
2. Upload the new py script to the absolute path specified by the alertscriptspath parameter, and the py file is as follows:
#! / usr/bin/env python# coding:utf-8''' [information] zabbix send email with pythonauthor: winggithub: https://github.com/wing324email: wing324@126.com'''from email import encodersfrom email.header import headerfrom email.mime.text import mimetextfrom email.utils import parseaddr, formataddrimport smtplibimport sysdef send_mail (_ to_email,_subject,_message): # define mail delivery smtp_host = 'smtp.xxx.xx' from_email =' xxx@xxx.xx' passwd = 'xxxxxx' msg = mimetext (_ message) 'plain','utf-8') msg [' subject'] = _ subject smtp_server = smtplib.smtp (smtp_host,25) smtp_server.login (from_email,passwd) smtp_server.sendmail (from_email, [_ to_email], msg.as_string () smtp_server.quit () if _ _ name__ = ='_ main__': send_mail (sys.argv [1], sys.argv [2], sys.argv [3])
3. Modify the permissions of python scripts
Chown-r zabbix:zabbix zabbix_send_email.pychmod 755 zabbix_send_email.py
4. Zabbix web configuration
Administration-> media types-> create media type
Create a test user administration-> users-> create user
Specify media:administration-> users-> create user-> media for the newly created user
Create action to realize email alarm configuration-> actions-> create action
5. Zabbix test to send email
Find a zabbix_agentd,kill on test to see if you have received an alarm email. Then restore it to see if you have received the restored message. If everything goes as expected, the alarm email for zabbix using the python script is now complete. If not as expected.
Tips:
If you use zabbix3.0, please note that the configuration of administration-> media types-> create media type is as follows:
This is the end of the article on "how zabbix uses python scripts to send alarm emails". Thank you for reading! I believe you all have a certain understanding of "how zabbix uses python scripts to send alarm emails". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.