Nagios nrpe and sudo: “NRPE: Unable to read output”
On CentOS, you can encounter the following behaviour when configuring an nrpe plugin with sudo:
/usr/lib/nagios/plugins/check_nrpe -H 1.2.3.4 -c check_exim
Mailqueue WARNING - query returned no output!
Given that check_exim is defined as follows, in nrpe.conf:
command[check_exim]=/usr/lib64/nagios/plugins/check_eximmailqueue -w 50 -c 100
And given (for completeness) its relative /etc/sudoers line as follows:
nagios ALL=(ALL) NOPASSWD:/usr/lib64/nagios/plugins/check_eximmailqueue
Then the problem is in the requiretty options in /etc/sudoers, enabled by default on CentOS. Simply comment it as follows:
#Defaults requiretty
After that the plugin should work as expected:
/usr/lib/nagios/plugins/check_nrpe -H 1.2.3.4 -c check_exim
Mailqueue OK - 11 messages on queue