天天看点

zabbix监控mysql主从状态

1. zabbix客户端编辑脚本 /tmp/shell/mysql_slave_status.sh

<code>#! /bin/bash</code>

<code>/usr/bin/mysql</code> <code>-p123456 -e </code><code>'show slave status \G;'</code><code>|</code><code>grep</code> <code>-E </code><code>"Slave_IO_Running|Slave_SQL_Running"</code><code>|</code><code>awk</code> <code>'{print $2}'</code><code>|</code><code>grep</code> <code>-c </code><code>"Yes"</code>

2. 授执行权限

    chmod +x mysql_slave_status.sh

3. 修改zabbix客户端配置文件/etc/zabbix/zabbix_agentd.conf

     UnsafeUserParameters=1

     UserParameter=mysql.slave.status, /tmp/shell/mysql_slave_status.sh

4. zabbix服务端测试

    zabbix_get -s 172.16.115.157 -p10050 -k mysql.slave.status

5. web端添加监控项和触发器

<a href="https://s3.51cto.com/wyfs02/M00/8E/D5/wKiom1jLu2aDsl-6AABgPuZD5lc852.png" target="_blank"></a>

<a href="https://s4.51cto.com/wyfs02/M00/8E/D5/wKiom1jLu2ax1o18AACsVEGyLcU680.png" target="_blank"></a>

本文转自 huangzp168 51CTO博客,原文链接:http://blog.51cto.com/huangzp/1907723,如需转载请自行联系原作者