Introduction: Nagios interface, see the monitoring MySQL service error is as follows:
Warning:NRPE:Unable to read output
1, go to the Nagios monitoring Server on the check
1.1, execute Check_nrpe command Remote call
Perform a Check_nrpe check on the monitoring server Nagios servers The MySQL status error is as follows:
[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 the service
Check other monitoring items such as check_users on the Nagios server side, as normal:
[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] ~]#
This proves that the nagios process is normal, can detect other monitoring items such as check_users, but Check_mysql fault error, or need to go to the MySQL server to analyze the problem exactly where.
2, on the monitored side MySQL server check
2.1, call the local Check_nrpe service, reported the same error as follows:
[email protected] ~]#/usr/lib/nagios/plugins/check_nrpe-hlocalhost-c check_mysql_status
Nrpe:unable to read output
[Email protected]mysqldb ~]#
Go to execute the check_mysql_status command inside the/etc/nagios/nrpe.cfg alone.
First use cat to find Check_mysql command line
[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
Execute, normal display as follows:
[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 Qu Eries 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 ~]#
From here you can see that the Check_mysql script is not a problem and is normal.
2.2, check the execution permission of the Check_mysql
[email protected] ~]# ll/usr/lib/nagios/plugins/check_mysql
-rwxrwxr-x. 1 root root 168272 July 8 14:54/usr/lib/nagios/plugins/check_mysql
[email protected] ~]#
See is the last X that shows the Execute permission, sudo to the Nagios account to see if it can be executed as follows:
[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 Qu Eries 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$
This indicates that both the Naigos account and the Check_mysql script can be executed, and the Check_mysql script path and execution permissions are all right.
2.3, check the Nagios permissions configuration on the inside of Sudo
Nagios remote invocation works by using the Nagios account to execute all check_xxx scripts, but my Nrpe client is installed by the root account, so the check_xxx script is also the root user, Does Nagios execute the su–root by default when it is called remotely, and then execute the check_msyql script command? So to edit the sudo configuration, modify the following, comment out the defaults requiretty, and then add a row of 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
After the modification, wq! forcibly saved out of Vim edit, and then perform this check_npre operation check, has resumed normal as follows:
[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 Qu Eries 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;;;
Then go to Nagios server side to perform Check_nrpe check, normal as follows:
[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 Qu Eries 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, then go to the Nagios monitor interface and check that the MySQL option is back to normal as shown in:
3 comes with some other reasons
There are a number of reasons why nrpe:unable to read output error, Google has the following other cases:
(1), the client configuration file/etc/nagios/npre.cfg does not add the Nagios server IP address, such as ALLOWED_HOSTS=127.0.0.1,IP after the IP is not filled out or fill in the wrong.
(2), check whether the client Nrpe permissions are readable, can be executed by Nagios, if Nagios permissions are not enough, you need to give X executable permissions.
(3), nrpe.cfg inside the commands command path is correct, such as some of the existing RPM installation also has source code installation, the path is different, source installation Ngios client path is/usr/local/nagios/libexec/check_ MySQL, and the RPM package installation path is/usr/lib/nagios/plugins/check_mysql.
From: http://blog.itpub.net/blog/post/id/1217246/
Reference article: http://blog.csdn.net/kakane/article/details/9615795