建立shell脚本检测MySql的AB复制简单步骤
下文主要给大家带来建立shell脚本检测MySql的AB复制简单步骤,希望这些内容能够带给大家实际用处,这也是我编辑建立shell脚本检测MySql的AB复制简单步骤这篇文章的主要目的。好了,废话不多说,大家直接看下文吧。
1. 建立一个Shell脚本,用于检测MySql的AB复制
vim/usr/local/nagios/libexec/check_mysqlab
#!/bin/bash#=========================================#File:checkmysqlab#Description:#Author:smileliuyb#Modify:smileliuyb#CreationDate:20130110#LastModified:20130110#=========================================ipadd=$1mysql-h$ipadd-uusername-ppasswd-e'stopslave;'&>/dev/null#mysql-h$ipadd-uusername-ppasswd-e'showslavestatus\G'&>dev/nullif[$?-eq0];thenmysql-h$ipadd-uusername-ppasswd-e'startslave;'&>/dev/nullnum=`mysql-h$ipadd-uamoebauser-pabc-e'showslavestatus\G'|grep-cYes`if[$num-eq2];thenecho"OK";exit0;elseecho"Error";exit2;fielseecho"Error";exit2;fi
chown nagios.nagios/usr/local/nagios/libexec/check_mysqlab
chmod a+x/usr/local/nagios/libexec/check_mysqlab
2.配置Nagios,在Nagios中加入新命令调用该脚本
vim/usr/local/nagios/etc/objects/commands.cfg
definecommand{command_namecheck_mysql_abcommand_line$USER1$/check_mysqlab$HOSTADDRESS$}
3.配置Nagios,建立新的被监控对象和被监控服务
vim /usr/local/nagios/etc/objects/localhost.cfg
definehost{host_name192.168.50.62alias50.62address192.168.50.62check_commandcheck-host-alivenotification_optionsd,u,rcheck_interval1max_check_attempts2contact_groupsadminsnotification_interval10notification_period24x7}
defineservice{host_name192.168.50.62service_descriptionmysqlabcheck_period24x7normal_check_interval2retry_check_interval1max_check_attempts3notification_period24x7notification_optionsw,u,c,rcheck_commandcheck_mysql_ab}
对于以上关于建立shell脚本检测MySql的AB复制简单步骤,大家是不是觉得非常有帮助。如果需要了解更多内容,请继续关注我们的行业资讯,相信你会喜欢上这些内容的。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。