First warning letter micro enterprises registered a micro letter, in order to achieve micro-channel alarm. Registered Address: https://work.weixin.qq.com/ .
- Applicant Micro Signal
1). Several important information to be recorded after a good application, behind zabbix server-side monitoring scripts need to use.
Login page - my business - Corporate ID:
. 2) create the application
login page - Application Management - Application - Create an application
record and get to agentid, Secret
agentid: XXXXX
Secret: XXXXX
3) add contacts.
Login page - Contacts - Add members
after the addition in order to receive the information. - zabbix server side configuration
1). Installation depends
used herein as a python monitor script, to be installed on zabbix sever python dependent server.yum install -y python-requests
2) Configuration python script
to create wechat.py default on zabbix sever server monitoring scripts directory.
cd / usr / lib / zabbix / alertscripts
vim wechat.py#!/usr/bin/env python #-*- coding: utf-8 -*- #author: Yu import requests import sys import os import json import logging # config for log logging.basicConfig(level = logging.DEBUG, format = '%(asctime)s, %(filename)s, %(levelname)s, %(message)s', datefmt = '%a, %d %b %Y %H:%M:%S', filename = os.path.join('/usr/lib/zabbix/alertscripts','weixin.log'), filemode = 'a') # Company ID corpid='xxxxxxx' # secret appsecret='xxxxxxxx' # AgentId agentid=xxxxxxx #Accesstoken token_url='https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=' + corpid + '&corpsecret=' + appsecret req=requests.get(token_url) accesstoken=req.json()['access_token'] # Message send msgsend_url='https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=' + accesstoken touser=sys.argv[1] subject=sys.argv[2] #toparty='3|4|5|6' message=sys.argv[3] params={ "touser": touser, # "toparty": toparty, "msgtype": "text", "agentid": agentid, "text": { "content": message }, "safe":0 } req=requests.post(msgsend_url, data=json.dumps(params)) logging.info('sendto:' + touser + ';;subject:' + subject + ';;message:' + message)
Remember to file empowerment
chown zabbix.zabbix Weixin
chmod 755 Weixin
3). Test
run weixin.py script/usr/lib/zabbix/alertscripts/weixin.py name "title test" "hello"
name: Recipient account (login enterprise micro-channel website - address book - Open a recipient - account)
title the Test: Title
hello: the specific content needs to be sent
if there is no error, then the recipient will be enterprise phone APP micro letter on receipt of this message, as shown below: - Zabbix Server Web is enabled with micro-channel alarm
1) adding an alarm medium.
Management ----> alarm media types -----> Create media types
add three script parameters:{ALERT.SENDTO} {ALERT.SUBJECT} {ALERT.MESSAGE}
Script name must configure the / usr / lib / zabbix / alertscripts script with the same name on zabbix server.
2) Create a user, adding the police media
management ----> users
Note: To fill the micro-enterprise contacts letter to members of the account, here are going to use micro-channel public number to receive alarm notification related information.
3) Create a trigger action
Configuration ----> Action ----> Action
create a mail transmission operation, configured trigger conditions: Trigger warning of greater than or equal warning
Configuration ----> Action ----> Operating
default title:故障{TRIGGER.STATUS},服务器名:{HOSTNAME1}发生: {TRIGGER.NAME}故障!
Message content:
告警主机:{HOSTNAME} 告警主机IP地址:{HOST.IP} 告警时间:{EVENT.DATE} {EVENT.TIME} 告警等级:{TRIGGER.SEVERITY} 告警信息: {TRIGGER.NAME} 告警项目:{TRIGGER.KEY1} 问题详情:{ITEM.NAME}:{ITEM.VALUE} 当前状态:{TRIGGER.STATUS}:{ITEM.VALUE1} 事件ID:{EVENT.ID}
Configuration ----> Action ----> Restore
default title:恢复{TRIGGER.STATUS}, 服务器名:{HOSTNAME1}: {TRIGGER.NAME}已恢复!
Message content:
告警主机:{HOSTNAME} 告警主机IP地址:{HOST.IP} 告警时间:{EVENT.DATE} {EVENT.TIME} 告警等级:{TRIGGER.SEVERITY} 告警信息: {TRIGGER.NAME} 告警项目:{TRIGGER.KEY1} 问题详情:{ITEM.NAME}:{ITEM.VALUE} 当前状态:{TRIGGER.STATUS}:{ITEM.VALUE1} 事件ID:{EVENT.ID}
4) The analog test micro-channel receive alarm notifications
to a new station is close monitoring host zabbix agent service, wait five minutes check to receive micro-channel alarm.
5) Using the general micro-channel is provided to accept the message
directly concerned with a micro-channel micro scan code table, you can receive notification and business enterprise applications use micro letter.
Methods: Log in micro enterprise management page letter - my business - micro table - invite attention of two-dimensional code
can be charged after attention.