当前位置:网站首页>zabbix email alarm and WeChat alarm
zabbix email alarm and WeChat alarm
2022-08-02 06:45:00 【palm nine】
配置zabbixEmail alerts and WeChat alarm.
一、邮件报警
1. 配置报警媒介类型
点击更新后,再次点击测试
测试成功
2. 创建用户
创建用户组并设置权限
创建用户
添加报警媒介
设置权限
3. 配置动作
1.创建主机组
2.创建模板
3.创建监控项
客户端
[[email protected] ~]# vim /etc/zabbix/zabbix_agent2.conf
###Option: UnsafeUserParameters
#Allow all characters to be passed in arguments to user-defined parameters.
#The following characters are not allowed:
#\ ' " ` * ? [ ] { } ~ $ ! & ; ( ) < > | # @
#Additionally, newline characters are not allowed.
#0 - do not allow
#1 - allow
#
#Mandatory: no
#Range: 0-1
#Default:
#UnsafeUserParameters=0
UnsafeUserParameters=1
###Option: UserParameter
#User-defined parameter to monitor. There can be several user-defined parameters.
#Format: UserParameter=<key>,<shell command>
#See 'zabbix_agentd' directory for examples.
#
#Mandatory: no
#Default:
#UserParameter=
UserParameter=os.login,who | wc -l
5.创建触发器
表达式:
6.创建动作
操作
Remember the template to givenode1主机
测试
Copy session number greater than3
用用户zhangsan登录zabbix
邮箱收件
Remove replication session,警报解除
查看Admin用户
二、微信报警
1. 注册企业微信
链接: https://work.weixin.qq.com/
Self-test also don't add members
2. 添加一个部门
Enter the address book add
Add member selection“Other departments import”
3. 创建一个应用
进入应用管理
Create the rememberAgentID和Secret:
Remember that the enterpriseID:
4. 微信企业号接口调试工具
https://open.work.weixin.qq.com/wwopen/devtool/interface/combine
点击调用接口,显示OK即可
5. 配置脚本
服务端操作
[[email protected] ~]# dnf provides */pip3
Last metadata expiration check: 2:32:57 ago on Mon 01 Aug 2022 02:07:36 PM CST.
python3-pip-9.0.3-22.el8.rocky.0.noarch : A tool for installing and managing Python3 packages
Repo : appstream
Matched from:
Filename : /usr/share/bash-completion/completions/pip3
python36-3.6.8-38.module+el8.5.0+671+195e4563.x86_64 : Interpreter of the Python programming language
Repo : appstream
Matched from:
Filename : /usr/bin/pip3
python38-pip-19.3.1-5.module+el8.6.0+794+eba84017.noarch : A tool for installing and managing Python3 packages
Repo : appstream
Matched from:
Filename : /usr/bin/pip3
python39-pip-20.2.4-7.module+el8.6.0+795+de4edbcc.noarch : A tool for installing and managing Python3 packages
Repo : appstream
Matched from:
Filename : /usr/bin/pip3
[[email protected] ~]# dnf install python36-3.6.8-38.module+el8.5.0+671+195e4563.x86_64
Into the specified directory to createshell脚本
[[email protected] ~]# cd /usr/lib/zabbix/alertscripts/
[[email protected] alertscripts]# vim webchat.sh
[[email protected] alertscripts]# cat webchat.sh
#!/bin/bash
CorpID="wwd5931acb806b41890c" # 你的企业id
Secret="BbUbI_g_4zwvgYjlRinxBu5V_xK8R1VRT-QiNLYW5O0" #你的SecretID
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 # 你的agentdid
local UserID="@all" # 发送的用户ID
local PartyID=1 # 部门ID
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
[[email protected] alertscripts]# chmod +x webchat.sh
[[email protected] alertscripts]# chown zabbix.zabbix webchat.sh
[[email protected] alertscripts]# systemctl restart zabbix-server.service
[[email protected] alertscripts]# ./webchat.sh test123
{"errcode":60020,"errmsg":"not allow to access from your ip, hint
[1659346334640291099389903], from ip: 111.19.34.233, more info at
https://open.work.weixin.qq.com/devtool/query?e=60020"}[[email protected] alertscripts]#
发现错误60020
Copy the url to view
https://open.work.weixin.qq.com/devtool/query?e=60020
进入应用管理>zabbix>企业可信IP
解决
[[email protected] alertscripts]# ./webchat.sh test123
{"errcode":0,"errmsg":"ok","msgid":"WpLDpQFMGSE843kRbNhgXXSkwRSv4Pitw4mtejX
IhGXxyByCLpHVi7TlK_didEkdb87tsQm5phjff8_ueWBWQ"}[[email protected] alertscripts]#
6. zabbix webInterface configuration WeChat alarm
进入:管理 > 报警媒介类型 > 创建媒体类型:
脚本参数
{ALERT.SENDTO}
{ALERT.SUBJECT}
{ALERT.MESSAGE}
主题
故障{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}
Add a resume
主题
恢复{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}
7. Users and medium of alarm correlation
8.Configuration action and operation
9.Man-made trigger test
恢复
邮件
边栏推荐
- 腾讯大咖分享 | 腾讯Alluxio(DOP)在金融场景的落地与优化实践
- Point Density-Aware Voxels for LiDAR 3D Object Detection Paper Notes
- 虚拟现实房产展示系统提前预见未来装修效果
- 程序员写PPT的小技巧
- 【漫画】2021满分程序员行为对照表(最新版)
- Deep learning - CNN realizes the recognition of MNIST handwritten digits
- HCIP BGP综合实验 建立对等体、路由反射器、联邦、路由宣告及聚合
- 程序员最重要的能力是什么?
- Mysql数据库 | 基于Docker搭建Mysql-8.0以上版本主从实例实战
- The virtual reality real estate display system foresees the future decoration effect in advance
猜你喜欢
npm 无法将“npm”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
Home NAS server (4) | MergerFS and SnapRaid data backup
51 MCU peripherals: DS18B20
MarkDown Formula Instruction Manual
What is the most important ability of a programmer?
双重for循环案例(用js打印九九乘法表)
Features and installation of non-relational database MongoDB
Nacos客户端启动出现9848端口错误分析(非版本升级问题)
Guarantee WIFI security in home and enterprise-with AC and AP networking experiment
6W+字记录实验全过程 | 探索Alluxio经济化数据存储策略
随机推荐
A detailed introduction to the deployment and usage of the Nacos registry
Luogu mini game Daquan (everyone who uses Luogu must know)
APT + Transform to realize multi module Application distributed Application life cycle
pytorch常用函数
国际顶会OSDI首度收录淘宝系统论文,端云协同智能获大会主旨演讲推荐
The virtual reality real estate display system foresees the future decoration effect in advance
深入剖析成员变量和局部变量的初始化问题
mysql索引失效的常见9种原因详解
APT + Transform 实现多模块应用Application生命周期分发
51 MCU peripherals: ADC
国际顶会OSDI首度收录淘宝系统论文,端云协同智能获大会主旨演讲推荐
Smart people's game improvement: Chapter 3, Lesson 2: "Number of Tongtong" (number)
leetcode-318.最大单词长度乘积
家用 NAS 服务器(4)| MergerFS和SnapRaid数据定时备份
Redis(十一) - 异步优化秒杀
驱动页面性能优化的3个有效策略
5款经典代码阅读器的使用方案对比
Thread Basics (1)
How to perform concurrent calculation (stability test and stress test)?
pytorch basic operations: classification tasks using neural networks