nagios 实现Mysql 主从同步状态的监控

一、系统环境

     

主机名

IP

nagios

192.168.15.111

mysql_s

192.168.15.21

二、操作步骤

2.1 mysql_s端的配置

2.1.1 编写check_mysql_slave监控脚本

     cd /usr/local/nagios/libexec   #切换到nagios监控插件所在文件夹

     vim check_mysql_slave       #開始编写mysql_slave监控脚本

注意:监控脚本中的mysql账户一定要新建一个,并设置有限的权限。

 

2.1.2 给脚本添加可运行权限

chmod 755 check_mysql_slave

-rwxr-xr-x   1 root root        471 Oct 16 12:59 check_mysql_slave

 

2.1.3编辑nrpe的配置文件

vim  /usr/local/nagios/libexec/etc/nrpe.cfg +204

#加入监控mysql 主从同步状态的命令

 command[check_mysql_slave]=/usr/local/nagios/libexec/check_mysql_slave

  

2.1.4又一次启动 nrpe 服务

 

2.1.5运行脚本測试输出

 

 [root@mysql_s  libexec]#  ./check_mysql_slave

 

OK mysql_s  is running

  

2.2  nagios端的配置:

 

2.2.1 改动已有的 /usr/local/nagios/etc/objects/service.cfg 配置文件

 

define service {

use                                          generic-service

host_name                            mysql_slave

service_description            check_21_mysql_replication_status

check_command                 check_nrpe!check_mysql_slave

max_check_attempts          3

normal_check_interval        2

retry_check_interval             2

check_period                        24x7

notification_interval             10

notification_period                24x7

notification_options            w,u,c,r

contact_groups                   admins

process_perf_data            1

}

 

2.2.2重新启动 nagios

 

[root@nagios objects]#/etc/init.d/nagios  checkconfig  #检查配置文件是否有误

[root@nagios objects]#/etc/init.d/nagios  reload           #又一次载入配置文件

Running configuration check...done.

Stopping nagios: done.

Starting nagios: done.

 

说明:假设nagios reload完成,监控页面尚未出现检測结果,能够手动測试

/usr/local/nagios/libexec/check_nrpe -H192.168.15.21 -c check_mysql_slave

 

2.2.3 终于效果图



原文地址:https://www.cnblogs.com/bhlsheji/p/5332467.html