当前位置:网站首页>zabbix怎样自定义mysql监控项并触发告警
zabbix怎样自定义mysql监控项并触发告警
2022-06-11 17:41:00 【雅冰石】
比如我想实现,假如有元数据锁Waiting for table metadata lock,则触发告警。
1 编写监控脚本
cd /opt/zabbix/scripts/
vi get_metalock.sh
添加如下内容:
#!/bin/bash
rm -rf /opt/zabbix/scripts/get_metalock.log
mysql -uMonitorUser -p密码 -e "
SELECT * FROM information_schema.processlist WHERE state='Waiting for table metadata lock';
quit" >> /opt/zabbix/scripts/get_metalock.log
v1=`cat /opt/zabbix/scripts/get_metalock.log |wc -l`
if [ $v1 -eq 0 ];then
echo 0
else
echo 1
fi#给脚本授权
chmod 755 /opt/zabbix/scripts/get_metalock.sh
2 创建配置文件
在/opt/zabbix/etc/zabbix_agentd.conf里定义的Include路径下创建配置文件。
示例:
Include=/opt/zabbix/etc/zabbix_agentd.conf.d/*.conf
则,
cd /opt/zabbix/etc/zabbix_agentd.conf.d/
新建一个以userparameter开头的,名字自定义的配置文件,示例:
vi userparameter_get_metalock.conf
添加如下内容:
UserParameter=get_metalock,sh /opt/zabbix/scripts/get_metalock.sh
#重启zabbix agent
systemctl restart zabbix_agentd
3 添加监控项
在现有mysql模板里创建监控项
配置-模板-监控项-创建监控项
键值和配置文件里定义的保持一致(UserParameter=后面的值)。

4 创建触发器

选择刚建的监控项:
![]()
这里设置last结果=1:

最终,自动生成如下结果:

自定义‘严重性’:

边栏推荐
- Sohu tout le personnel a été escroqué, quels problèmes ont été exposés?
- Hash table, inheritance
- Test and analysis of tidb write hotspot
- [foundation of deep learning] learning of neural network (3)
- Bentley 使用 Authing 快速实现应用系统与身份的集成
- 简单理解事件
- How does Sister Feng change to ice?
- 7-1 are prime numbers
- 6-3 批量求和(*)
- Ffmpeg hard codec inter QSV
猜你喜欢

sql server中关于FORCESCAN的使用以及注意项

Custom or subscription? What is the future development trend of China's SaaS industry?

你还不懂线程池的设计及原理吗?掰开揉碎了教你设计线程池

Kubernetes deploys elk and collects container logs using filebeat

活动 | Authing 首次渠道合作活动圆满落幕

ffmpeg CBR精准码流控制三个步骤

QLineEdit 设置输入掩码

Chorus翻译

Vscode configures eslint to automatically format an error "auto fix is enabled by default. use the single string form“

tidb-写热点的测试及分析
随机推荐
sql server中移除key lookup书签查找
Vscode configures eslint to automatically format with an error "the setting is deprecated. use editor.codeactionsonsave instead with a source“
Chorus translation
信息安全数学基础 Chapter 4——二次剩余与方根
From manufacturing to "intelligent manufacturing", explore the way for manufacturing enterprises to break the situation
[foundation of deep learning] learning of neural network (3)
7-1 均是素数
6-3 batch sum (*)
Dynamic: capturing network dynamics using dynamic graph representation learning
Semaphore PV operation of process interaction and its code implementation
7-2 h0107. Pig-Latin
Authoring share | understanding saml2 protocol
04_ Feature engineering feature selection
Custom or subscription? What is the future development trend of China's SaaS industry?
6-3 读文章(*)
6-7 文件读写操作
R语言寻找数据集缺失值位置
How to simplify a lot of if... Elif... Else code?
光纤熔接知识汇总【转载自微信公众号弱电智能化工程2018】
Threejs uses indexeddb cache to load GLB model