0
点赞
收藏
分享

微信扫一扫

Zabbix item 自定义监控MySQL主从同步

尤克乔乔 2022-08-17 阅读 108


[root@localhost sh]# chmod o+x mysql_repl_status.sh 
[root@localhost sh]# cat mysql_repl_status.sh
#!/bin/bash
/usr/local/mysql55/bin/mysql -e "show slave status\G" | grep Running | grep -i yes | wc -l
[root@localhost sh]# ./mysql_repl_status.sh
2


[root@localhost sh]# /usr/local/mysql55/bin/mysql -e "show slave status\G" | head -n 13
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.179.99
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 439
Relay_Log_File: localhost-relay-bin.000002
Relay_Log_Pos: 253
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

[root@localhost ~]# vim /etc/zabbix_agentd.conf
UserParameter=mysql.repl.status,/data/sh/mysql_repl_status.sh


[root@localhost ~]# systemctl restart zabbix-agent



[root@localhost ~]# zabbix_get -s 192.168.179.100 -k "mysql.repl.status"
ERROR 1227 (42000) at line 1: Access denied; you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation
0

[root@localhost sh]# chmod u+s /usr/local/mysql55/bin/mysql



[root@localhost ~]# zabbix_get -s 192.168.179.100 -k "mysql.repl.status"
2

Zabbix item 自定义监控MySQL主从同步_bash

 

Zabbix item 自定义监控MySQL主从同步_监控类_02

 

Zabbix item 自定义监控MySQL主从同步_监控类_03

添加触发器

 

Zabbix item 自定义监控MySQL主从同步_监控类_04

 

Zabbix item 自定义监控MySQL主从同步_bash_05

 测试触发器 

[root@localhost ~]# /usr/local/mysql55/bin/mysql -e "stop slave;" 
[root@localhost ~]# /usr/local/mysql55/bin/mysql -e "show slave status\G" | grep Running | grep -i yes | wc -l
0

 

Zabbix item 自定义监控MySQL主从同步_触发器_06

 

Zabbix item 自定义监控MySQL主从同步_bash_07

举报

相关推荐

0 条评论