Nagios監控MySQL報錯:NRPE: Unable to read output的詳細解決過程
前言:nagios介面上,看到監控mysql服務報錯如下:
Warning:NRPE: Unable to read output
1,去nagios監控伺服器上check下
1.1,執行check_nrpe命令遠端呼叫
在監控端nagios伺服器上執行check_nrpe檢查mysql狀態報錯如下:
[root@mysqlvm2 ~]# /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
[root@mysqlvm2 ~]#
1.2,檢查下別的check服務
在nagios伺服器端檢查別的監控項比如check_users,正常如下:
[root@mysqlvm2 ~]# /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
[root@mysqlvm2 ~]#
這裡證明,nagios流程是正常的,能檢測到別的監控項比如check_users,但是check_mysql故障報錯,還是需要去mysql伺服器上再去分析問題到底出在哪裡。
2,在被監控端mysql伺服器check
2.1,呼叫本地的check_nrpe服務,報一樣的錯誤如下:
[root@mysqldb ~]# /usr/lib/nagios/plugins/check_nrpe -Hlocalhost -c check_mysql_status
NRPE: Unable to read output
[root@mysqldb ~]#
去單獨執行/etc/nagios/nrpe.cfg裡面的check_mysql_status命令。
先用cat找到check_mysql的命令列
[root@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='nagiosq@0512' -d test
執行,正常顯示如下:
[root@ mysqldb ~]# /usr/bin/sudo /usr/lib/nagios/plugins/check_mysql -unagios -P3306 -s /usr/local/mysql/mysql.sock -Hlocalhost --password='nagiosq@0512' -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;;;
[root@ mysqldb ~]#
從這裡可以看到check_mysql指令碼沒有問題,是正常的。
2.2,檢查下check_mysql的執行許可權
[root@mysqldb ~]# ll /usr/lib/nagios/plugins/check_mysql
-rwxrwxr-x. 1 root root 168272 7月 8 14:54 /usr/lib/nagios/plugins/check_mysql
[root@mysqldb ~]#
看到是最後一個x,表明有執行許可權,sudo到nagios賬號,看是否能執行,如下所示:
[root@mysqldb ~]# su - nagios
-bash-4.1$ /usr/lib/nagios/plugins/check_mysql -unagios -P3306 -s /usr/local/mysql/mysql.sock -Hlocalhost --password='nagiosq@0512' -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指令碼的,但是我的nrpe客戶端是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操作檢查,已經恢復正常如下:
[root@mysqldb ~]# /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;;;
再去nagios伺服器端執行check_nrpe檢查,正常如下:
[root@mysqlvm2 ~]# /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;;;
[root@mysqlvm2 ~]#
2.4,再去nagios監控介面,檢視mysql選項已經恢復正常,如下圖所示:
3 附帶一些其他原因
引起NRPE: Unable to read output報錯的原因有很多種,google了下其它的情況如下:
(1),客戶端配置檔案/etc/nagios/npre.cfg裡面沒有新增nagios伺服器IP地址,比如 allowed_hosts=127.0.0.1,IP後面IP沒有填寫或者填寫有誤。
(2),查客戶端nrpe的許可權是否可讀,可被nagios執行,如果nagios許可權不夠,需要賦予X可執行許可權。
(3),nrpe.cfg裡面commands命令路徑是否正確,比如有些既有rpm方式安裝的也有原始碼安裝的,兩者路徑不一樣,原始碼安裝ngios客戶端路徑是/usr/local/nagios/libexec/check_mysql,而rpm包安裝路徑是/usr/lib/nagios/plugins/check_mysql。
參考文章:http://blog.csdn.net/kakane/article/details/9615795
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30633755/viewspace-2127680/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 詳細記錄一次npm i canvas報錯的解決過程NPMCanvas
- nagios配置過程詳解iOS
- Nagios各元件簡述及nrpe詳解iOS元件
- Centos 7安裝與配置nagios監控詳細圖解(二)CentOSiOS圖解
- Centos 7安裝與配置nagios監控詳細圖解(一)CentOSiOS圖解
- Nagios使用check_mysql監控mysqliOSMySql
- 天兔監控SQL Azure報錯解決案例SQL
- Nginx下構建nagios監控平臺Nagios+nrpe+nagios-plugins+pnp安裝文件薦NginxiOSPlugin
- 將Nagios監控資訊存入MySQLiOSMySql
- Nagios 裡面監控MySQL 監控事務夯住(RUNNING)報警通知iOSMySql
- 解決MMM啟動監控報錯的問題
- MySQL MHA詳細搭建過程MySql
- MySQL伺服器部署nagios監控MySql伺服器iOS
- 完美解決xhost +報錯: unable to open display
- Nagios監控mysql從庫報錯:libmysqlclient.so.18: cannot open shared object fileiOSMySqlIBMclientObject
- nagios監控例項 -- PostgreSQL監控iOSSQL
- 解決Ubuntu報錯 E: Unable to locate package yumUbuntuPackage
- Goldengate for nrpe監控指令碼Go指令碼
- Nrpe 監控Linux系統Linux
- Nrpe for Windows監控檢測命令Windows
- MySQL儲存過程詳解 mysql 儲存過程MySql儲存過程
- 安裝sysbench過程報錯,解決辦法
- Cacti監控MySQL實現過程中碰到的問題解彙總MySql
- 開源監控解決方案nagios+pnp4nagios+nconf+ndoutils整合部署iOS
- nagios的配置(監控端和被監控端)iOS
- MySQL 建立儲存過程報錯MySql儲存過程
- ORACLE監控系統錯誤日誌過程Oracle
- nagios監控windows 報NSClient - ERROR: Invalid passwordiOSWindowsclientError
- mysql儲存過程詳解MySql儲存過程
- nagios批量新增監控iOS
- 使用nagios監控oracleiOSOracle
- MySQL MGR單主模式詳細搭建過程MySql模式
- mysql5.7.23安裝詳細過程MySql
- Oracle->Mysql dblink 建立詳細過程OracleMySql
- MySQL 中出現報錯提示: ‘Variable ‘XXX‘ is a read only variable‘的解決方法MySql
- MySQL主從複製的詳細過程介紹MySql
- MySQL儲存過程詳解 mysql 儲存過程linkMySql儲存過程
- 使用nrpe監控Goldengate程式指令碼Go指令碼