zoukankan      html  css  js  c++  java
  • 利用 nagios 自带的插件来监控 mysql 的主从同步状态 (监控多实例)

    利用 nagios 自带的插件来监控 mysql 的主从同步状态 (监控多实例)  

     

    Nagios监控Mysql主从同步

    ################################################

    使用check_mysql插件 检查mysql主从同步(3307为从库)

    ################################################

     

    [主动方式]

     

    1、调试check_mysql主从同步的命令

     

    登录到从库的服务器上进行如下操作:

     

    [root@centos4 ~]# mysql -u root -p -S /data/3307/mysql.sock

     

    mysql> grant super,replication slave on *.* to hackbase@'192.168.1.%' identified by 'wanqiu';

    Query OK, 0 rows affected (0.00 sec)

     

    mysql> exit

    Bye

     

    接下来我们登录到nagios服务端:

     

    1、用check_mysql插件进行检测

     

    [root@nagios ~]# cd /usr/local/nagios/libexec/

     

    [root@nagios libexec]# ./check_mysql -uhackbase -p wanqiu -s /data/3307/mysql.sock -P3307  -H 192.168.1.123 -S

    Uptime: 10848  Threads: 1  Questions: 24  Slow queries: 0  Opens: 13  Flush tables: 1  Open tables: 7  Queries per second avg: 0.002 Slave IO: Yes Slave SQL: Yes Seconds Behind Master: 0

     

    2、编辑commands.cfg

     

    [root@nagios libexec]# cd ../etc/objects/

     

    [root@nagios objects]# vi host.cfg

     

    ******************************************

    define host{

            use                     linux-server

            host_name               mysql-tongbu

            alias                   mysql-tongbu

            address                 192.168.1.123

            process_perf_data       1

            }

     

    define hostgroup{

            hostgroup_name  linux-servers

            alias           Linux Servers

            members         mysql-tongbu

            }

     

    define hostextinfo {

            host_name             mysql-tongbu

            action_url            /nagios/pnp/index.php?host=$HOSTNAME$

    }

    ******************************************

     

    [root@nagios objects]# vi commands.cfg

     

    ******************************************

    # 'check_mysql_slave' command definition

    define command{

            command_name    check_mysql_slave

            command_line    $USER1$/check_mysql -uhackbase -p wanqiu -s /data/3307/mysql.sock -P3307  -H 192.168.1.123 -S

            }

    ******************************************

    3、添加检查mysql同步的服务配置

     

    [root@nagios objects]# vi service.cfg

     

    **********************************************************

    define service {

            use                             generic-service

            host_name                       mysql-tongbu

            service_description             check_mysql_slave

            check_command                   check_mysql_slave

            max_check_attempts      2

            normal_check_interval   4

            retry_check_interval    4

            check_period            24x7

            notification_interval   1440

            notification_period     24x7

            notification_options    w,u,c,r

            contact_groups          admins

            process_perf_data       1

    }

    **********************************************************

     

    4、检查语法并重起nagios

     

    /etc/init.d/nagios checkconfig

    /etc/init.d/nagios reload

     

    5、进入界面查看变化

     

    不同步状态时的内容,界面服务那一行为红色

     

    check_mysql_slave  CRITICAL 04-24-2011 17:20:11 0d 0h 0m 21s 1/2

    Slave IO: No Slave SQL: Yes Seconds Behind Master: (null) 

     

    同步状态时的内容,界面服务那一行为绿色

     

    check_mysql_slave OK 04-24-2011 17:28:11 0d 0h 2m 35s 1/2 Uptime: 182 Threads: 1 Questions: 7 Slow queries: 0 Opens: 11 Flush tables: 1 Open tables: 6 Queries per second avg: 0.038

    Slave IO: Yes Slave SQL: Yes Seconds Behind Master: 0 

     

    如下图所示:

     

     

    利用 nagios 自带的插件来监控 mysql 的主从同步状态 (监控多实例) - 倾听 晚秋 - 倾听 晚秋

      


    (全文完)

  • 相关阅读:
    csc一些命令简记
    Winform(C#.NET)自动更新组件的使用及部分功能实现(续)
    Winform(C#.NET)自动更新组件的使用及部分功能实现
    mssql的日期函数,如何取得当前年月日,当前时间,当前月份,当前天数,一年中第几天?
    在jexus下如何简单的配置多站点
    让asp.net和php同时在Linux上跑起来
    raspberrypi(树莓派)上安装mono和jexus,运行asp.net程序
    centos6.3与jexus5.4.4配置支持php(wordpress)
    Kaggle系列1:手把手教你用tensorflow建立卷积神经网络实现猫狗图像分类
    小记tensorflow-1:tf.nn.conv2d 函数介绍
  • 原文地址:https://www.cnblogs.com/helloyb/p/2870143.html
Copyright © 2011-2022 走看看