nagios監控mysql主從複製

nagios監控mysql主從複製 

 環境:

Centos5.6 mysql只做同步指定庫,沒有同步mysql庫用戶數據
登陸從服務器mysql,添加驗證的用戶
grant replication client on *.* to 'nagios'@localhost identified by '123456';
flush privileges;
查看是否添加成功
select user,host from mysql.user
在從服務器安裝 nrpe,然後在配置文件nrpe.cfg加入一行
command[check_mysql_slave]=/usr/local/nagios/libexec/check_mysql_slave
添加這個文件內容
#!/bin/sh 
declare -a slave_is
slave_is=($(/usr/local/mysql/bin/mysql -unagios -p123456 -e "show slave status\G"|grep Running |awk '{print $2}'))
if [ "${slave_is[0]}" = "Yes" -a "${slave_is[1]}" = "Yes" ]
     then
     echo "OK -slave is running" 
     exit 0
else
     echo "Critical -slave is error" 
     exit 2
fi
再執行這個腳本,觀察輸出情況
/usr/local/nagios/libexec/check_nrpe -H 192.168.10.231
/usr/local/nagios/libexec/check_nrpe -H 192.168.10.231 -c check_mysql_slave
在主監控服務裏面添加了重啓
define service {
host_name 192.168.10.232
service_description check_mysql_slave
check_period 24x7
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
contact_groups mygroup
notification_interval 5
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_mysql_slave
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章