zabbix installation for referenceZABBIX4.0 Source Code Installation, corporate WeChat alarm needs to go in three steps, the first step to apply for the public account of the enterprise, the second step to write the alarm script, the third step is to configure the ZABBIX-Web interface
enterWeChat public platform, select the company’s WeChat, fill in the registration according to the requirements. After the registration is completed, log in to the company’s WeChat, click to apply to the applet, create an application
Circles are filled in. Here you can choose the department or the designated personnel.
After the creation is completed, it will be transferred to the application management interface. Agentid and Secret need to be recorded. In addition, it is necessary to record the company ID. Click my company. At the bottom, there is an enterprise ID.
The company’s WeChat has been completed above, and then scripts on the zabbix-server side
[[email protected] alertscripts]# pwd
/opt/zabbix-4.1/share/zabbix/alertscript
[[email protected]Alertscripts]# Cat Weichat.py
#!/usr/bin/env python
#-*-coding: UTF-8-*-
#date: 2018-04-20
#Comment: zabbix access to WeChat alarm script
Import Requests
import sys
Import OS
import json
Import logging
#Logging.basicconfig (level = logging.debug, format = ' %(asctime) s, %(filename) s, %(levelName) s, (Message) s', datefmt =' %a, %d %b %b % Y%H:%S ', FILENAME = OS.Path.Join ('/Data/Zabbix ',' We
Ixin.log '), Filemode =' A ')
Corpid = 'xx' #c c
appsecret = 'xx' #Secret
agentid =[email protected] alertscripts]# chmod +x weichat.py
[[email protected] alertscripts]# ./weichat.py wechatname Test "This is test message"
Click Management —–> Alarm Media Type ——> Create Media Types ——> Type Select the script, and then fill in the script name (consistent with the name of the server script), three The parameters must be filled, namely users, events, and warning content
{ALERT.SENDTO} {ALERT.SUBJECT} {ALERT.MESSAGE}
Management —–> User —–> Alarm Media (the recipient is a department user, or you can set the department ID (unbet, it should be possible)
Configuration —–> Action, set the trigger conditions