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

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

自定义‘严重性’:

边栏推荐
- 信息安全数学基础 Chapter 3——有限域(一)
- [solution] codeforces round 798 (Div. 2)
- 6-1 how many words are needed to form a sentence?
- 端口规划与APJ
- 6-3 读文章(*)
- Difference between require and ES6 import
- tidb-cdc同步mysql没有的特性到mysql时的处理
- How does Sister Feng change to ice?
- CLP information -5 keywords to see the development trend of the financial industry in 2022
- Mathematical basis of information security Chapter 2 - congruence
猜你喜欢
![[MySQL] detailed explanation of redo log, undo log and binlog (4)](/img/67/6e646040c1b941c270b3efff74e94d.png)
[MySQL] detailed explanation of redo log, undo log and binlog (4)

How does Sister Feng change to ice?

Service learning notes 01 start method and life cycle

05_ Feature Engineering - dimension reduction

Qlineedit set input mask

Authing biweekly news: authing forum launched (4.25-5.8)

which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_ mod

Port planning and APJ

Bentley 使用 Authing 快速实现应用系统与身份的集成

Valid parentheses ---2022/02/23
随机推荐
聚类方法汇总
Ffmpeg hard codec inter QSV
[solution] codeforces round 798 (Div. 2)
7-1 are prime numbers
Test and analysis of tidb write hotspot
Mathematical foundations of information security Chapter 3 - finite fields (I)
Test basis: black box test
[online problem] timeout waiting for connection from pool
自动化测试-Selenium
Mathematical foundations of information security Chapter 3 - finite fields (II)
Typescipt Basics
智能化整体图例,布线、安防、广播会议、电视、楼宇、消防、电气图的图例【转自微信公众号弱电课堂】
6-3 批量求和(*)
Arraylist集合、对象数组
【线上问题】Timeout waiting for connection from pool 问题排查
Hands on deep learning - multiple input and output channels in the convolution layer
有效的括号---2022/02/23
信息安全数学基础 Chapter 3——有限域(二)
How to simplify a lot of if... Elif... Else code?
QLineEdit 设置输入掩码