nagios 實現Mysql 主從同步狀態的監控

來源:互聯網
上載者:User

nagios 實現Mysql 主從同步狀態的監控

一、系統內容

主機名稱

IP

nagios

192.168.15.111

mysql_s

192.168.15.21

二、操作步驟

2.1 mysql_s端的配置

2.1.1 編寫check_mysql_slave監控指令碼

cd /usr/local/nagios/libexec #切換到nagios 監控外掛程式所在目錄

vimcheck_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 -H192.168.15.21 -c check_mysql_slave

2.2.3 最終

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.