centos6.5中nagios監控mysql運行狀態方法

來源:互聯網
上載者:User

先說一下本機環境,centos 6.5 64位,nagios是用yum裝的,版本是Nagios Core 3.5.1,內建的就有check_mysql

1,修改commands.cfg

# vim /etc/nagios/objects/commands.cfg #添加以下內容 
 
define command{ 
 command_name check_mysql 
 command_line $USER1$/check_mysql -H $ARG1$ -u $ARG2$ -p $ARG3$ 

在這裡要注意,這三個參數伺服器,使用者名稱和密碼

2,修改監控機器檔案localhost.cfg

# vim /etc/nagios/objects/localhost.cfg #添加以下內容 
 
define service{ 
 use local-service 
 host_name localhost 
 service_description MySQL 
 check_command check_mysql!localhost!root!root 

!localhost!root!root分別對應$ARG1$,$ARG2$,$ARG3$,這三個參數

3,修改用戶端nrpe.cfg

# vim /etc/nagios/nrpe.cfg #添加以下內容 
 
command[check_mysql]=/usr/lib64/nagios/plugins/check_mysql -H localhost -u root -p root 
在這裡要注意,等號後面的命令是可執行檔,並且不能有錯。


[root@node1 objects]# /usr/lib64/nagios/plugins/check_mysql -H localhost -u root -p root 
Uptime: 78680 Threads: 1 Questions: 3488 Slow queries: 0 Opens: 126 Flush tables: 1 Open tables: 133 Queries per second avg: 0.044 

4,重啟nagios和nrpe

# /etc/init.d/nrpe start 
# /etc/init.d/nagios start 

如果重啟nagios報以下錯誤:

Running configuration check... CONFIG ERROR! Restart aborted. Check your Nagios configuration.

解決辦法:

[root@node1 objects]# /usr/sbin/nagios -v /etc/nagios/nagios.cfg 
檢測設定檔錯在什麼地方,你就可以很輕鬆的修改錯誤的地方。如果沒有報錯,就說明配置OK了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.