Oct 042010
NRPE: Unable to read output
In a sudden flash of inspiration, I realized I could replace some cronjobs and emails with a Nagios plugin. This article assumes you know about Nagios and how to write a plugin. The main goal here is to show you a debugging approach I found.The problem
The problem was the the following entry in /usr/local/etc/nrpe.cfg:command[check_freshports_queues]=/usr/local/libexec/nagios/check_freshports_queueWhen running it, I saw:
$ /usr/local/libexec/nagios/check_nrpe2 -H nyi-vpn -c check_freshports_queues NRPE: Unable to read outputA Google search shows this means the script it not producing any output. The script contains:
#!/bin/sh cd /usr/websites/freshports.org/scripts/ ./queue-status.plI started by adding an echo $? to the script. Now the output changes
$ /usr/local/libexec/nagios/check_nrpe2 -H nyi-vpn -c check_freshports_queues 13That’s the problem. The script isn’t running at all. No error output though. Let me try another trick. On the remote server, become root, and then run the command from nrpe.cfg via su. This allows you to run the command as the nagios user:
# su -m nagios -c ./queue-status.pl Can't locate email.pm in @INC (@INC contains: /usr/local/lib/perl5/5.8.9/BSDPAN /usr/local/lib/perl5/site_per l/5.8.9/mach /usr/local/lib/perl5/site_perl/5.8.9 /usr/local/lib/perl5/5.8.9/mach /usr/local/lib/perl5/5.8.9 .) at utilities.pm line 13. Compilation failed in require at ./queue-status.pl line 11. BEGIN failed--compilation aborted at ./queue-status.pl line 11.After a bit of playing, I had to do chmod o+rx on various .pm files. Once that was done, success:
$ /usr/local/libexec/nagios/check_nrpe2 -H supernews-vpn -c check_freshports_queues Queues are OKWhile this may not help you directly, it may give you some clues.