Linux – NRPE: Unable to read output

linuxnagiosnrpe

I try to monitor MySQL database:

[root@monitored.com ~]# su nagios -c /usr/lib/nagios/plugins/check_mysql
Uptime: 18014 Threads: 1 Questions: 6 Slow queries: 0 Opens: 12 Flush tables: 1 Open tables: 6 Queries per second avg: 0.000

but I've got unexpected error:

[ec2-user@monitoring.com ~]$ /usr/lib/nagios/plugins/check_nrpe -H monitored.com -c check_mysql
NRPE: Unable to read output

What's wrong?

Best Answer

One good way to debug why the command being executed is not returning any valid output is to use strace. For example, I just had a problem running the check_linux_raid command via NRPE.

Run strace -f -p <nrpe pid>, and then execute the command manually from the system running nagios (e.g. /usr/lib64/nagios/plugins/check_nrpe -H remotename -c commandname -a arg1 arg2 ...).

Scan the output of strace for errors, such as permission denied or other similar errors that may occur. For example, in my case, selinux was denying permission to a file when running from the remote machine, even though that user has local access to that file.