zabbix alarm information aggregation and enterprise wechat reception

Keywords: Linux Zabbix Redis Python pip

1. Code download address

2. Purpose of development

This development is mainly based on the revision of the version described by the author, mainly adding the enterprise wechat receiving alarm, email receiving alarm, slack receiving alarm, and distinguishing different alarms to receive different alarm information
3. zabbix configuration
3-1.zabbix Actions
For special settings of Actions, Default subject is very important, which is a sign of convergence.

Default subject


Default message


Recovery subject


Recovery message


3-2.Media types
Just pass the subject parameter here. -- alarm function: zabbix alarm calls this function to push event id into redis.
See the third part for redis installation

#!/usr/bin/env python
import redis
import sys
r = redis.StrictRedis(host='**.**.**.**', port=6379)

4. Operation part
4-1. Environmental installation

#Install python, mysql and redis modules
pip install redis
pip install pymysql
yum install gcc python-devel
pip install requests
//Install Python 3.6

4-2. Program deployment
a. ZABBIX? Server needs to install redis, with no password
b. In addition to the zabbix directory where needs to be placed, other programs can be placed in the custom directory
c. Program execution mode: usr/local/python3/bin/python /data/police/
5. Configuration details

redis_ip = ""  #redis ip address
redis_port = 6379 #redis port

mysql_ip = "" #The mysql address of zabbix
mysql_port = 3306
mysql_user = "zabbix"
mysql_pwd = "xiyou2018"
mysql_db = "zabbix"
actionid = ["3"]   #ZABBIX DB select actionid, name from actions; find the corresponding actionid value by searching
send_to_users_0 = ["",""]  #Alarm user mailbox, send ﹤ to ﹤ users ﹤ num > starts from 0, 0 corresponds to the first value in the actionid list, and so on, which realizes that different actionids correspond to different alarm user groups
# send_to_users_1 = ["",""]
slack_status = 1 #Whether to use slack alarm, the value is 1| 0, 1 means to use
slack_webhook = [""]
email_status = 1 #Use mail alarm or not, the value is 1| 0, 1 means use
recevier_server_smtp = "" #Sender mailbox server
recevier_user = ""  #Sender email account
recevier_pwd = "asdfasdfasdf"
weixin_status = 1 #Whether to use the enterprise wechat alarm, the value is 1| 0, 1 means to use
weixin_webhook = ["",] 
#For multiple groups of enterprise wechat, you only need to put the corresponding webhook address in, and the action s correspond in turn

Posted by tomdchi on Wed, 13 May 2020 08:34:31 -0700