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

magic
2014-10-23 / 0 评论 / 2 阅读 / 正在检测是否收录...

一、系统环境**

主机名IP
nagios192.168.15.111
mysql_s192.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 -H 192.168.15.21 -c check_mysql_slave

2.2.3**最终效果图
**

0

评论 (0)

取消