当前位置:网站首页>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
恢复
邮件
边栏推荐
- Not annotated parameter overrides @NonNullApi parameter
- Features and installation of non-relational database MongoDB
- 淘系资深工程师整理的300+项学习资源清单(2021最新版)
- The virtual reality real estate display system foresees the future decoration effect in advance
- 回文串求解的进阶方法
- Difference between npm and yarn
- 51 MCU Peripherals: Infrared Communication
- 直播系统聊天技术(八):vivo直播系统中IM消息模块的架构实践
- Nacos installation configuration and single-machine deployment tutorial
- Point Density-Aware Voxels for LiDAR 3D Object Detection 论文笔记
猜你喜欢
HCIP BGP综合实验 建立对等体、路由反射器、联邦、路由宣告及聚合
Leetcode parentheses matching problem -- 32. The longest parentheses effectively
MarkDown Formula Instruction Manual
机器学习——支持向量机原理
国际顶会OSDI首度收录淘宝系统论文,端云协同智能获大会主旨演讲推荐
代码编世界 科技创未来
Nacos客户端启动出现9848端口错误分析(非版本升级问题)
About the directory structure of the web application
MySQL索引常见面试题(2022版)
点云旋转到参考坐标系方向(最小方向包围盒方法)
随机推荐
Mysql数据库 | 基于Docker搭建Mysql-8.0以上版本主从实例实战
Redis(十二) - Redis消息队列
BGP experiment (route reflector, federation, route optimization)
关于鸿蒙系统 JS UI 框架源码的分析
股价屡创新低 地产SaaS巨头陷入困境 明源云该如何转型自救?
Double for loop case (use js jiujiu printing multiplication table)
[OpenCV from entry to practice] image processing technology [pixel] (the most detailed in the whole network)
leetcode-318.最大单词长度乘积
oracle 远程连接数据库
There are more and more talents in software testing. Why are people still reluctant to take the road of software testing?
使用TinkerPop框架对GDB增删改查
flex布局(弹性布局)
C语言基础知识梳理总结:零基础入门请看这一篇
[Cartoon] 2021 full score programmer behavior comparison table (latest version)
Kingdee International: Lost in half a year and last year, how does the business model of frantically burning money continue
The virtual reality real estate display system foresees the future decoration effect in advance
Difference between npm and yarn
从入门到精通的MySQL数据库视频教程
使用jOOQ 3.14合成外键在视图上写隐式连接
反向解析dns服务器