NRPE Not Working with Perl on RHEL 6
Posted: Tue Jun 26, 2012 8:30 am
I've spent weeks beating me head off NRPE. I developed a plugin in Perl that works from the commandline when run as the nagios user, but, it will not work over NRPE at all. I had thought it was something to do with my script, but after some more experimentation today, I think it's a problem with NRPE, or with the NRPE package from RPMForge for RHEL6.
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:
This works from the commandline as the user nagios, so I added it to NRPE with the following command:
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:
This executed via NRPE, and returned the following output:
I checked on the server for the location of strict.pm, it is located at /usr/share/perl5/strict.pm, and as you can see, that path IS shown in @INC.
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.
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.