I decided to go right back to first principles, and try get the absolute most elemental script I could to work, so I wrote the following plugin that simply always returns OK:
Code: Select all
#!/usr/bin/perl
use strict;
use warnings;
print "OK - this dummy test always returns OK\n";
exit 0;command[check_test]=/usr/lib64/nagios/plugins/check_true.pl
This gives the following error over NRPE: NRPE: Unable to read output
I decided to simplify things even more, and commented out the two use statements, THEN it worked! It turns out that as soon as I use ANYTHING, even standard parts of Perl, NRPE breaks.
To investigate further I wrote a little wrapper shell script to capture STDERR as well as STDOUT when the script is run by NRPE. The wrapper I used was simply:
Code: Select all
#!/bin/sh
out=`/usr/lib64/nagios/plugins/check_true.pl 2>&1`
echo $outCode: Select all
Can't locate strict.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/lib64/nagios/plugins/check_true.pl line 3. BEGIN failed--compilation aborted at /usr/lib64/nagios/plugins/check_true.pl line 3.I'm at a loss to see why such a trivial script could work when run as the user nagios, but break so badly when run as the user nagios through NRPE? What does NRPE do to the environment that could break Perl this badly? And does anyone know a work-around other than re-writing my entire plugin in a different language?
Thanks,
Bart.