当前位置:网站首页>ZABBIX realizes nail monitoring alarm
ZABBIX realizes nail monitoring alarm
2022-07-22 19:44:00 【Yabingshi】
demand :
take Zabbix The alarm information is sent to the nail group .
One Create a nail robot
Two To configure zabbix
2.1 Deploy nailing script
mkdir /opt/zabbix/alertscripts
mkdir /opt/zabbix/log
# modify /opt/zabbix/etc/zabbix_server.conf, Set the monitoring script path
AlertScriptsPath=/opt/zabbix/alertscripts
# restart zabbix server
systemctl restart zabbix_server
# Deploy monitoring scripts
cd /opt/zabbix/alertscripts
vi dingding.py, Add the following :
#!/usr/bin/env python
#coding:utf-8
import requests,json,sys,os,datetime
webhook=" Previously copied webhook Address "
user=sys.argv[1]
text=sys.argv[3]
data={
"msgtype": "text",
"text": {
"content": text
},
"at": {
"atMobiles": [
user
],
"isAtAll": False
}
}
headers = {'Content-Type': 'application/json'}
x=requests.post(url=webhook,data=json.dumps(data),headers=headers)
if os.path.exists("/opt/zabbix/log/dingding.log"):
f=open("/opt/zabbix/log/dingding.log","a+")
else:
f=open("/opt/zabbix/log/dingding.log","w+")
f.write("\n"+"--"*30)
if x.json()["errcode"] == 0:
f.write("\n"+str(datetime.datetime.now())+" "+str(user)+" "+" Send successfully "+"\n"+str(text))
f.close()
else:
f.write("\n"+str(datetime.datetime.now()) + " " + str(user) + " " + " fail in send " + "\n" + str(text))
f.close()
# Give permissions to scripts
chmod 755 dingding.py
# Manually test whether the message can be sent to the nail
① Make sure zabbix server Servers can be networked
# Make sure you can ping through .
ping oapi.dingtalk.com
② Get the next personal nail account id, Example :
③ test
./dingding.py Nail No Custom theme " Keywords set above "
Example :
./dingding.py uaj1zks ceshi " The alarm "
/*
If an error ImportError: No module named requests, be yum install python-requests -y
*/
See if the nail robot has received the message :
2.2 To configure zabbix web
2.2.1 Add alarm script to zabbix
management —— Alarm medium type —— Create alarm media type :
{ALERT.SENDTO}
{ALERT.SUBJECT}
{ALERT.MESSAGE}
2.2.2 Configure users
Configuration here Admin user :
After adding , Remember to click ‘ to update ’.
2.2.3 Create action
stay ‘ operation ’ Click on ‘ add to ’:
/*
The alarm :{EVENT.NAME}
Alarm host :{HOSTNAME1}
Alarm time :{EVENT.DATE} {EVENT.TIME}
Alarm level :{TRIGGER.SEVERITY}
The alarm information : {TRIGGER.NAME}
Alarm items :{TRIGGER.KEY1}
Details of the problem :{ITEM.NAME}:{ITEM.VALUE}
current state :{TRIGGER.STATUS}:{ITEM.VALUE1}
event ID:{EVENT.ID}
*/
stay ‘ Recovery operation ’ Click on ‘ add to ’:
/*
Alarm host :{HOSTNAME1}
Alarm time :{EVENT.DATE} {EVENT.TIME}
Alarm level :{TRIGGER.SEVERITY}
The alarm information : {TRIGGER.NAME}
Alarm items :{TRIGGER.KEY1}
Details of the problem :{ITEM.NAME}:{ITEM.VALUE}
current state :{TRIGGER.STATUS}:{ITEM.VALUE1}
event ID:{EVENT.ID}
*/
Finally, remember to click on the front ‘ action ’ Tab out ‘ add to ’ Add these actions .
2.3 Verify the alarm function
Under configuration zabbix Monitoring of a component ( Example mysql), Stop the component , Verify whether the alarm can be received .
The alarm information is as follows :
-- This article refers to Zabbix Realize nail group alarm _ Xia Shiman CharmaineXia The blog of -CSDN Blog _zabbix Nail alarm
边栏推荐
- [take you to learn C, take you to fly] branch structure in Chapter 3 of C language programming (3rd Edition) of Zhejiang University Edition (exercise 3)
- js map与foreach区别
- oracle用一条sql查出哪些数据不在某个表里
- 记一次 .NET 某RFID标签管理系统 CPU 暴涨分析
- Force deduction solution summary 735 planetary collision
- Jackson 解析 JSON 详细教程
- oracle怎样将字符串转为多行
- DNSmasq 安装与配置
- 数据湖(十八):Flink与Iceberg整合SQL API操作
- Neo4j - Cypher 语法示例
猜你喜欢
随机推荐
派生类的构造函数和析构函数
zabbix怎样创建只监控某个端口状态的模板
Atr5179 single pole double throw switch chip replaces as179-92lf
树和二叉树:树的概念
C# 自动生成字典(数据多的时候)
由浅入深详解NLP中的Adapter技术
7.21 排列与二进制
where与having的区别
Explain the adapter technology in NLP from simple to deep
Neo4j 示例:三国志人物关系图谱
pytest接口自动化测试框架 | pytest断言
7.17 最低票价
CV520国产替代CI520非接触式读写器读卡芯片
解决Couldn‘t determine repo type for URL
数据湖(十八):Flink与Iceberg整合SQL API操作
Pytest interface automated testing framework | plug-in secondary development practice
ATR5179单刀双掷开关芯片替代AS179-92LF
Leetcode notes
Definition of derived classes
Setting proxy method in PHP curl request