Nagios顯示器MySQL一個錯誤:NRPE: Unable to read output具體的解決過程

來源:互聯網
上載者:User

標籤:

前言:nagios介面。見監測mysql服務錯誤,如下面:

Warning:NRPE: Unable to read output

 

 

1,跟nagios顯示器server上check下

1.1。運行check_nrpe命令遠程調用

在監控端nagiosserver上運行check_nrpe檢查mysql狀態報錯例如以下:

[[email protected] ~]# /usr/lib/nagios/plugins/check_nrpe  -H192.xx.180.xx -c check_mysql_status

NRPE: Unable to read output

You have new mail in /var/spool/mail/root

[[email protected] ~]#

 

1.2,檢查下別的check服務

在nagiosserver端檢查別的監控項比方check_users,正常例如以下:

[[email protected] ~]# /usr/lib/nagios/plugins/check_nrpe  -H192.xx.180.xx -c check_users

USERS OK - 2 users currently logged in |users=2;8;15;0

[[email protected] ~]#

 

這裡證明。nagios流程是正常的。能檢測到別的監控項比方check_users,可是check_mysql故障報錯,還是須要去mysqlserver上再去分析問題究竟出在哪裡。

 

 

2,在被監控端mysqlservercheck

2.1。調用本地的check_nrpe服務。報一樣的錯誤例如以下:

[[email protected] ~]# /usr/lib/nagios/plugins/check_nrpe -Hlocalhost -c check_mysql_status

NRPE: Unable to read output

[[email protected]mysqldb ~]#

 

去單獨運行/etc/nagios/nrpe.cfg裡面的check_mysql_status命令。

先用cat找到check_mysql的命令列

[[email protected]mysqldb ~]# cat /etc/nagios/nrpe.cfg |grep check_mysql_status

command[check_mysql_status]=/usr/bin/sudo  /usr/lib/nagios/plugins/check_mysql -unagios -P3306 -s /usr/local/mysql/mysql.sock -Hlocalhost --password=‘[email protected]‘ -d test 

運行。正常顯示範範例如以下:

[[email protected] mysqldb ~]# /usr/bin/sudo  /usr/lib/nagios/plugins/check_mysql -unagios -P3306 -s /usr/local/mysql/mysql.sock -Hlocalhost --password=‘[email protected]‘ -d test

Uptime: 1122870  Threads: 108  Questions: 11559152  Slow queries: 1278  Opens: 3190  Flush tables: 1  Open tables: 395  Queries per second avg: 10.294|Connections=844188c;;; Open_files=49;;; Open_tables=395;;; Qcache_free_memory=209024;;; Qcache_hits=51724c;;; Qcache_inserts=73877c;;; Qcache_lowmem_prunes=5599c;;; Qcache_not_cached=2572345c;;; Qcache_queries_in_cache=1985;;; Queries=11559153c;;; Questions=10724833c;;; Table_locks_waited=0c;;; Threads_connected=107;;; Threads_running=2;;; Uptime=1122870c;;;

[[email protected] mysqldb ~]#

從這裡能夠看到check_mysql指令碼沒有問題,是正常的。

 

2.2。檢查下check_mysql的運行許可權

[[email protected] ~]# ll /usr/lib/nagios/plugins/check_mysql

-rwxrwxr-x. 1 root root 168272 7月   8 14:54 /usr/lib/nagios/plugins/check_mysql

[[email protected] ~]#

看到是最後一個x,表明有運行許可權,sudo到nagios帳號。看能否運行,例如以下所看到的:

[[email protected] ~]# su - nagios

-bash-4.1$ /usr/lib/nagios/plugins/check_mysql -unagios -P3306 -s /usr/local/mysql/mysql.sock -Hlocalhost --password=‘[email protected]‘ -d test

Uptime: 1124403  Threads: 106  Questions: 11586454  Slow queries: 1278  Opens: 3190  Flush tables: 1  Open tables: 395  Queries per second avg: 10.304|Connections=846235c;;; Open_files=49;;; Open_tables=395;;; Qcache_free_memory=211696;;; Qcache_hits=51786c;;; Qcache_inserts=73915c;;; Qcache_lowmem_prunes=5732c;;; Qcache_not_cached=2578541c;;; Qcache_queries_in_cache=1890;;; Queries=11586455c;;; Questions=10750088c;;; Table_locks_waited=0c;;; Threads_connected=105;;; Threads_running=2;;; Uptime=1124403c;;;

-bash-4.1$

這裡表明既是naigos帳號也能夠運行check_mysql指令碼的,check_mysql指令碼路徑以及運行許可權都沒有問題。都是能夠的。

 

2.3,檢查sudo的裡面的nagios許可權配置

Nagios遠程調用運行原理是,通過nagios帳號來運行全部的check_xxx指令碼的。可是我的nrpeclient是root帳號安裝的。所以的check_xxx指令碼也是root使用者所屬,nagios在遠程調用的時候是否預設運行了su – root,然後在運行check_msyql指令碼命令?所以去編輯sudo配置,改動例如以下,把Defaults    requiretty凝視掉,然後加入一行nagios ALL=(ALL) NOPASSWD:/usr/lib/nagios/plugins/check_mysql。

 

vim  /etc/sudoers


#表示不須要終端控制

#Defaults    requiretty 

 

#表示通過nagios命令運行check_mysql命令不須要密碼。

nagios ALL=(ALL) NOPASSWD:/usr/lib/nagios/plugins/check_mysql

 

改動完。wq!強行儲存退出vim編輯,然後運行本次check_npre操作檢查。已經恢複正常例如以下:

[[email protected] ~]# /usr/lib/nagios/plugins/check_nrpe -Hlocalhost -c check_mysql_status

Uptime: 1123659  Threads: 110  Questions: 11573270  Slow queries: 1278  Opens: 3190  Flush tables: 1  Open tables: 395  Queries per second avg: 10.299|Connections=845248c;;; Open_files=49;;; Open_tables=395;;; Qcache_free_memory=227704;;; Qcache_hits=51751c;;; Qcache_inserts=73892c;;; Qcache_lowmem_prunes=5656c;;; Qcache_not_cached=2575554c;;; Qcache_queries_in_cache=1943;;; Queries=11573271c;;; Questions=10737891c;;; Table_locks_waited=0c;;; Threads_connected=109;;; Threads_running=2;;; Uptime=1123659c;;;

 

再去nagiosserver端運行check_nrpe檢查,正常例如以下:

[[email protected] ~]# /usr/lib/nagios/plugins/check_nrpe  -H192.xx.180.xx -c check_mysql_status

Uptime: 1123673  Threads: 110  Questions: 11573464  Slow queries: 1278  Opens: 3190  Flush tables: 1  Open tables: 395  Queries per second avg: 10.299|Connections=845264c;;; Open_files=49;;; Open_tables=395;;; Qcache_free_memory=227704;;; Qcache_hits=51751c;;; Qcache_inserts=73892c;;; Qcache_lowmem_prunes=5656c;;; Qcache_not_cached=2575596c;;; Qcache_queries_in_cache=1943;;; Queries=11573465c;;; Questions=10738069c;;; Table_locks_waited=0c;;; Threads_connected=109;;; Threads_running=2;;; Uptime=1123673c;;;

[[email protected] ~]#

 

2.4,再去nagios監控介面,查看mysql選項已經恢複正常,例如以所看到的:


3 附帶一些其他原因

  引起NRPE: Unable to read output報錯的原因有非常多種,google了下其他的情況例如以下:

  (1),client設定檔/etc/nagios/npre.cfg裡面沒有加入nagiosserverIP地址。比方 allowed_hosts=127.0.0.1,IP後面IP沒有填寫或者填寫有誤。

  (2),查clientnrpe的許可權是否可讀,可被nagios運行,假設nagios許可權不夠。須要賦予X可運行許可權。

  (3)。nrpe.cfg裡面commands命令路徑是否正確,比方有些既有rpm方式安裝的也有原始碼安裝的,兩者路徑不一樣,原始碼安裝ngiosclient路徑是/usr/local/nagios/libexec/check_mysql,而rpm包安裝路徑是/usr/lib/nagios/plugins/check_mysql。

  (4)。client設定檔中面有2個一模一樣的命令。比方/etc/nagios/nrpe.cfg裡面有例如以下2個check_zombie_procs配置命令:

command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 10 -c 15 -s Z
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_iostat -w

        那麼就會報NRPE: Unable to read output的錯誤。由於兩個命令混亂了。不知道去運行哪一個了。

 

 來自: http://blog.itpub.net/blog/post/id/1217246/

 

參考文章:http://blog.csdn.net/kakane/article/details/9615795

著作權聲明:本文博主原創文章。部落格,未經同意不得轉載。

Nagios顯示器MySQL一個錯誤:NRPE: Unable to read output具體的解決過程

聯繫我們

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