六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 941|回复: 0

Nagios监控MySQL从库状态

[复制链接]
 楼主| 发表于 2015-8-24 15:23:00 | 显示全部楼层 |阅读模式
Nagios监控MySQL从库状态
写了一个插件,MySQL slave status monitor plugin for Nagios,用来监控MySQL的主从复制和从库状态。
使用方法:
01#1.登上运行有mysql从库的服务器上,下载脚本放到nagios的libexec目录下,例如:

02cd /usr/local/nagios/libexec/

03wget http://down.chengyongxu.com/check_mysql_slave_status

04#

05#2.改属主,加执行权限

06chown nagios:nagios check_mysql_slave_status

07chmod 755 check_mysql_slave_status

08#

09#3.在nrpe.cfg文件中增加下边一行,参数根据你的需要修改

10#----------------------------增加文字-开始----------------------------

11command[check_mysql_slave_status]=/usr/local/nagios/libexec/check_mysql_slave_status -S /var/lib/mysql/mysql.sock -u user -p password

12#----------------------------增加文字-结束----------------------------

13#

14#4.保存退出后重启nrpe

15service nrpe restart

16#

17#5.要主监控服务器上增加一个服务监控

18#----------------------------增加文字-开始----------------------------

19    define service{

20    host_name       10.0.0.166

21    service_description       check_mysql_slave_status

22    check_command       check_nrpe!check_mysql_slave_status

23    max_check_attempts       3

24    check_interval       10

25    retry_interval       5

26    check_period       24x7

27    notification_interval       30

28    notification_period       24x7

29    notification_options      w,u,c

30    #contacts       contacts(*)

31    contact_groups       sa_groups

32    }

33#----------------------------增加文字-结束----------------------------

34#

35#6.保存退出后重启nagios

36service nagios restart

37#

38#7.在MySQL中对你这个监控脚本要使用的用户进行授权

39#例如

40grant replication client,super on *.* to chengyongxu.com@'localhost' identified by 'the password'



脚本内容请见:http://down.chengyongxu.com/check_mysql_slave_status
转载请标明出处
http://www.chengyongxu.com/blog/ ... %E7%8A%B6%E6%80%81/


Nagios监控MySQL从库状态

该会员没有填写今日想说内容.
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表