您好,登錄后才能下訂單哦!
客戶端操作:
yum install -y nagios-plugins nagios-plugins-all nrpe nagios-plugins-nrpe#安裝
vim /etc/nagios/nrpe.cfg #更改客戶端的nrpe配置文件
allowed_hosts=192.168.20.168 #IP更改成監(jiān)控端的地址,如果是多個(gè)使用,分割開
#漏了這個(gè)后期會出現(xiàn)CHECK_NRPE: Error - Could not complete SSL handshake. 的
vim /usr/lib64/nagios/plugins/check_slave #編輯監(jiān)控腳本
#!/bin/sh
slave_R=($(/usr/local/mysql/bin/mysql -e "show slave status\G"|grep Running |awk '{print $2}'))
if [ "${slave_R[0]}" = "Yes" -a "${slave_R[1]}" = "Yes" ]
then
echo "OK RN2-slave is running"
exit 0
else
echo "Critical RN2-slave is error"
exit 2
fi
chmod +x /usr/lib64/nagios/plugins/check_slave #加上可執(zhí)行權(quán)限,否則NRPE: Unable to read output
vim /etc/nagios/nrpe.cfg #編輯nrpe.cfg,加上如下:
command[check_slave]=/usr/lib64/nagios/plugins/check_slave
執(zhí)行監(jiān)控腳本:
sh /usr/lib64/nagios/plugins/check_slave #輸出OK
/etc/init.d/nrpe start #啟動nrpe
服務(wù)端:
vim /etc/nagios/conf.d/192.168.20.130.cfg
define host{
use linux-server
host_name 192.168.20.130
alias 20.130
address 192.168.20.130
}
define service{
use generic-service
host_name 192.168.20.130
service_description check_slave
check_command check_nrpe!check_slave
max_check_attempts 2
normal_check_interval 2
contact_groups common
notifications_enabled 1
notification_period 24x7
notification_options w,u,c,r
}
nagios -v /etc/nagios/nagios.cfg #檢查腳本,無錯(cuò),繼續(xù)下一步
/etc/init.d/nagios restart
登陸監(jiān)控查看:
停掉客戶端的mysql,查看:
收到告警郵件:
恢復(fù)mysql的slave端至正常收;收到恢復(fù)到正常的郵件了:
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。