zabbix利用微信报警

一、背景介绍

报警的方式有很多种,比如常用的邮件报警,短信,微信等。那这篇文章主要是实现微信报警。

值得注意的是,之前使用微信企业公众号,现在微信企业公众号更新成企业微信了。所以直接注册企业微信,进入下一步即可。

准备工作:

1)注册一个企业微信号

注册页面地址:https://mp.weixin.qq.com/cgi-bin/registermidpage?action=index&lang=zh_CN

 

 

进入首页,如图:

 2)添加一个部门  ,我这里加的是运维部,然后添加人员

 

 

问题:微信中怎么接收到这个消息呢?(企业应用后台添加自定义应用可以在普通微信中搜索到吗)

方法:选择 ‘连接微信’ ---->微工作台

 

好了,现在微信发送的三个必要参数已经找到

AgentId:    1000002
Secret:       eoGD4567t8u9i00p456789043567890456789P94s
CorpID:      wwvevfgrw56798908a
脚本测试:(在zabbix 的服务器端操作)

[root@localhost ~]# 
[root@localhost ~]# cd /usr/local/zabbix/share/zabbix/alertscripts
[root@localhost alertscripts]# wget https://raw.githubusercontent.com/OneOaaS/weixin-alert/master/weixin_linux_amd64

[root@localhost alertscripts]# mv weixin_linux_amd64 weixin
[root@localhost alertscripts]# chmod +x weixin 
[root@localhost alertscripts]# chown zabbix:zabbix weixin

修改zabbix.conf:
grep alertscripts /usr/local/zabbix/etc/zabbix_server.conf 
AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts          #修改为你自己的路径

 
[root
@localhost alertscripts]# ./weixin --corpid=wwvevfgrw56798908a --corpsecret=eoGD4567t8u9i00p456789043567890456789P94s --msg="您好,告警测试" -user=QuTianFen --agentid=1000002 正确返回信息如下: {"errcode":0,"errmsg":"ok","invaliduser":""}

 接下来可以正常在zabbix的web页面添加 微信报警媒介

猜你喜欢

转载自www.cnblogs.com/tianfen/p/9259798.html