Zabbix微信告警实战

企业微信地址,个人可注册

https://work.weixin.qq.com/

登录企业微信

  1. 企业 -> 微工作台里可以直接微信关注,无需要下载企业微信
  2. 通讯录里的账号在发微信脚本中要用到
  3. 应用与小程序可创建应用

发微信的python脚本/usr/local/zabbix/alertscripts/zabbix_wx.py

#!/usr/bin/python

# -*- coding: utf-8 -*-

import json

import sys

import urllib,urllib2

agentid = 'xxx'

corpid = 'xxx'

corpsecret = 'xxx'

#get tocken

gettoken_url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=' + corpid + '&corpsecret=' + corpsecret

token_file = urllib2.urlopen(gettoken_url)

token_data = token_file.read().decode('utf-8')

token_json = json.loads(token_data)

my_token = token_json['access_token']

#send wechart

touser=sys.argv[1]  #many user: 'zhangsan|wangwu'

content=sys.argv[2] #content

post_content = {

        "touser":touser,

        "agentid":agentid,

        "msgtype": "text",

        "text":{

                "content":content,

        }

}

json_content = json.dumps(post_content)

url = 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=' + my_token

response = urllib2.urlopen(url,json_content)

print(response.read().decode('utf-8'))

测试脚本

/usr/local/zabbix/alertscripts/zabbix_wx.py 'zhuang_weihong' 'disk is not enough'

Zabbix微信告警配置步骤

  1. 写一个微信告警的脚本,这个已经测试成功
  2. 报警媒介添加微信告警
  3. 用户设置报警媒介
  4. 创建触发器动作
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值