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


边栏推荐
- 2022年T电梯修理考题及答案
- nodejs installation and environment configuration
- v-model
- Use of lombok annotation @RequiredArgsConstructor
- 云开发校园微社区微信小程序源码/二手交易/兼职交友微信小程序开源源码
- C程序编译和预定义详解
- 静态/动态代理模式
- LeetCode:899. 有序队列【思维题】
- Kubernetes:(十一)KubeSphere的介绍和安装(华丽的篇章)
- Security First: Tools You Need to Know to Implement DevSecOps Best Practices
猜你喜欢

Use of lombok annotation @RequiredArgsConstructor

Flask Framework Beginner-06-Add, Delete, Modify and Check the Database

lombok注解@RequiredArgsConstructor的使用

Snake game bug analysis and function expansion

JS 保姆级贴心,从零教你手写实现一个防抖debounce方法

MallBook 助力SKT思珂特教育集团,立足变化,拥抱敏捷交易

LeetCode:899. 有序队列【思维题】

Web APIs BOM- 操作浏览器:swiper 插件

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

idea中diagram使用
随机推荐
Is there any jdbc link to Youxuan database documentation and examples?
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
关联接口测试
FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
Parquet encoding
lombok注解@RequiredArgsConstructor的使用
Flink原理流程图简单记录
pytorch应用于MNIST手写字体识别
Snake game bug analysis and function expansion
Multithreading JUC Learning Chapter 1 Steps to Create Multithreading
实例037:排序
What is SVN (Subversion)?
web端动效 lottie-web 使用
Apache DolphinScheduler actual combat task scheduling platform - a new generation of distributed workflow
2022年T电梯修理考题及答案
Hey, I had another fight with HR in the small group!
flinkcdc 消费 mysql binlog 没有 sqltype=delete 的数据是什么原
Security First: Tools You Need to Know to Implement DevSecOps Best Practices
JS 从零教你手写节流throttle
FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed