当前位置:网站首页>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 测试


边栏推荐
- 持续投入商品研发,叮咚买菜赢在了供应链投入上
- 一篇文章看懂JS闭包,从执行上下文角度解析有趣的闭包
- 大佬们,读取mysql300万单表要很长时间,有什么参数可以优惠,或者有什么办法可以快点
- 简单排序(暑假每日一题 14)
- mpf5_定价Bond_yield curve_Spot coupon_duration_有效利率_连续复利_远期_Vasicek短期_CIR模型Derivatives_Tridiagonal_ppf
- Example 041: Methods and variables of a class
- DDTL: Domain Transfer Learning at a Distance
- Sticker Spelling - Memory Search / Shape Pressure DP
- 5.scrapy中间件&分布式爬虫
- 实例036:算素数
猜你喜欢

工程制图复习题

- heavy OpenCV 】 【 mapping

Qt中对象树的机制介绍以及底层实现,各种结果分析:(以及自己写容易犯错的点)

IDEA02:配置SQL Server2019数据库

2022 China Computing Power Conference released the excellent results of "Innovation Pioneer"

esp32 releases robot battery voltage to ros2 (micro-ros+CoCube)

Flask Framework Beginner-05-Command Management Manager and Database Use

priority_queue元素为指针时,重载运算符失效

静态/动态代理模式

Flask Framework Beginner-06-Add, Delete, Modify and Check the Database
随机推荐
【Untitled】
2022年茶艺师(中级)考试试题模拟考试平台操作
【云原生】DevOps(六):Jenkins流水线
ssh服务详解
Download install and create/run project for HBuilderX
各位大佬好,麻烦问一下flink cdc oracle写入doris的时候,发现cpu异常,一下下跑
Apache DolphinScheduler actual combat task scheduling platform - a new generation of distributed workflow
FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
Instance, 038: the sum of the diagonal matrix
JS 保姆级贴心,从零教你手写实现一个防抖debounce方法
Parquet encoding
- heavy OpenCV 】 【 mapping
Flask Framework Beginner-06-Add, Delete, Modify and Check the Database
Quickly build a website with static files
FeatureNotFound( bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested:
pytorch应用于MNIST手写字体识别
简单排序(暑假每日一题 14)
APP电商如何快速分润分账?
工程制图名词解释-重点知识
融云「音视频架构实践」技术专场【内含完整PPT】