当前位置:网站首页>Zabbix set up email alert + enterprise WeChat alert
Zabbix set up email alert + enterprise WeChat alert
2022-08-04 02:09:00 【weijiajia123456】
一.告警流程
The first thing to do is to create a template
Create triggers and items in templates
创建监控项
创建触发器
1.1添加报警媒介

1.2声音设置

1.3创建用户

1.4配置动作
为触发器 The number of system user logins is greater than3 添加动作



1.5配置触发器
二.邮件告警
2.1 配置报警媒介类型



三.企业微信告警
3.1注册企业微信

3.2创建应用

创建完成记住AgentID和Secret:
记住企业ID
3.3微信企业号接口调试工具
https://open.work.weixin.qq.com/wwopen/devtool/interface/combine

3.4 配置脚本
在zabbix server上操作
1、安装requests组件
yum install -y python-pip
cd /usr/lib/zabbix/alertscripts/
vim webchat.sh
#!/bin/bash
CorpID="填写自己的"
Secret="Fill in your own key"
GURL="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$CorpID&corpsecret=$Secret"
Token=$(/usr/bin/curl -s -G $GURL |awk -F\": '{print $4}'|awk -F\" '{print $2}')
# echo $Token
PURL="https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$Token"
function body(){
local int agentid=1000002
local UserID="@all"
local PartyID=1
local Msg=$(echo "[email protected]" | cut -d" " -f3-)
printf '{\n'
printf '\t"touser": "'"$UserID"\"",\n"
printf '\t"toparty": "'"$PartyID"\"",\n"
printf '\t"msgtype": "text",\n'
printf '\t"agentid": "'"$agentid"\"",\n"
printf '\t"text": {\n'
printf '\t\t"content": "'"$Msg"\""\n"
printf '\t},\n'
printf '\t"safe":"0"\n'
printf '}\n'
}
/usr/bin/curl --data-ascii "$(body $1 $2 $3)" $PURL

chmod +x webchat.sh
chown zabbix.zabbix webchat.sh
systemctl restart zabbix-server.service
./webchat.sh test123
测试结果: {"errcode":0,"errmsg":"ok","msgid":"WpLDpQFMGSE843kRbNhgXeSwGcdfomP8jofhSehE-FH04XKtV2Va6IFCYxr16b3Wl8VFiOqXf8m1WepSC7usOQ"}[[email protected] alertscripts]#
3.4 zabbix web界面中配置微信报警

选择脚本,The script name is what we wrotewebchat.sh
Add a message template
Modify the default alarm template
设置动作
默认接收人:故障{TRIGGER.STATUS},服务器:{HOSTNAME1}发生: {TRIGGER.NAME}故障!
默认信息:
告警主机:{HOSTNAME1}
告警时间:{EVENT.DATE} {EVENT.TIME}
告警等级:{TRIGGER.SEVERITY}
告警信息: {TRIGGER.NAME}
告警项目:{TRIGGER.KEY1}
问题详情:{ITEM.NAME}:{ITEM.VALUE}
当前状态:{TRIGGER.STATUS}:{ITEM.VALUE1}
事件ID:{EVENT.ID}
设置恢复:
恢复:恢复主旨:恢复{TRIGGER.STATUS}, 服务器:{HOSTNAME1}: {TRIGGER.NAME}已恢复!
恢复信息:
告警主机:{HOSTNAME1}
告警时间:{EVENT.DATE} {EVENT.TIME}
告警等级:{TRIGGER.SEVERITY}
告警信息: {TRIGGER.NAME}
告警项目:{TRIGGER.KEY1}
问题详情:{ITEM.NAME}:{ITEM.VALUE}
当前状态:{TRIGGER.STATUS}:{ITEM.VALUE1}
事件ID:{EVENT.ID}
3.5给用户添加报警媒介

3.6 配置动作

3.7 测试


边栏推荐
- Summary of GNSS Articles
- How to copy baby from Taobao (or Tmall store) through API interface to Pinduoduo interface code docking tutorial
- 各位大佬好,麻烦问一下flink cdc oracle写入doris的时候,发现cpu异常,一下下跑
- Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
- ssh服务详解
- Thinkphp commonly used techniques
- FeatureNotFound( bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested:
- Example 040: Reverse List
- 编写 BOLL 心得体会
- splice随机添加和删除的写法
猜你喜欢

- heavy OpenCV 】 【 mapping

esp32发布机器人电池电压到ros2(micro-ros+CoCube)

2022G1工业锅炉司炉考试练习题及模拟考试

DHCP服务详解

织梦响应式酒店民宿住宿类网站织梦模板(自适应手机端)

Parquet encoding

DDTL: Domain Transfer Learning at a Distance
![Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.](/img/10/87c0bedd49b5dce6fbcd28ac361145.png)
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.

v-model

2022广东省安全员A证第三批(主要负责人)考试题库及模拟考试
随机推荐
SAP SD模块前台操作
Kubernetes:(九)coredns(浪不动了)
Example 041: Methods and variables of a class
Engineering drawing review questions (with answers)
JS 保姆级贴心,从零教你手写实现一个防抖debounce方法
html select tag assignment database query result
Android interview questions and answer analysis of major factories in the first half of 2022 (continuously updated...)
Installation and configuration of nodejs+npm
编写 BOLL 心得体会
Example 037: Sorting
Example 040: Reverse List
内网穿透-应用
nodejs installation and environment configuration
Parquet encoding
融云「音视频架构实践」技术专场【内含完整PPT】
【云原生】DevOps(六):Jenkins流水线
Promise 解决阻塞式同步,将异步变为同步
idea中diagram使用
Promise solves blocking synchronization and turns asynchronous into synchronous
5. Scrapy middleware & distributed crawler