当前位置:网站首页>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 测试
边栏推荐
- 实例035:设置输出颜色
- 安全至上:落地DevSecOps最佳实践你不得不知道的工具
- 实例036:算素数
- 实例037:排序
- 2022年T电梯修理考题及答案
- 网页三维虚拟展厅为接入元宇宙平台做基础
- 实例038:矩阵对角线之和
- Continuing to pour money into commodities research and development, the ding-dong buy vegetables in win into the supply chain
- Intranet penetration - application
- Kubernetes:(十一)KubeSphere的介绍和安装(华丽的篇章)
猜你喜欢
实例041:类的方法与变量
Small Turtle Compilation Notes
MallBook联合人民交通出版社,推动驾培领域新发展,开启驾培智慧交易新生态
mpf5_定价Bond_yield curve_Spot coupon_duration_有效利率_连续复利_远期_Vasicek短期_CIR模型Derivatives_Tridiagonal_ppf
SAP SD模块前台操作
MySQL高级-读写分离-分库分表
Parquet encoding
出海季,互联网出海锦囊之本地化
小程序:扫码打开参数解析
Android interview questions and answer analysis of major factories in the first half of 2022 (continuously updated...)
随机推荐
Example 040: Reverse List
Simple sorting (summer vacation daily question 14)
大佬们,读取mysql300万单表要很长时间,有什么参数可以优惠,或者有什么办法可以快点
出海季,互联网出海锦囊之本地化
P3384 【模板】轻重链剖分/树链剖分
sudo 权限控制,简易
Slipper - virtual point, shortest path
FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
第08章 索引的创建与设计原则【2.索引及调优篇】【MySQL高级】
APP电商如何快速分润分账?
Use of lombok annotation @RequiredArgsConstructor
5.scrapy中间件&分布式爬虫
Flink jdbc connector 源码改造sink之 clickhouse多节点轮询写与性能分析
nodejs+express realizes the access to the database mysql and displays the data on the page
Installation and configuration of nodejs+npm
Quickly build a website with static files
KunlunBase 1.0 is released!
Example 035: Setting the output color
浏览器存储
工程制图复习题