I'm using some Perl-based scripts for service checks in Nagios and I get (Service check did not exit properly)
and (null)
as the result in Nagios, but the script works great on the command line.
I've seen solutions online suggesting to disable the internal Perl interpreter by setting enable_embedded_perl=0
in the Nagios configuration or by specifying the path to an interpreter explicitly. This did not help with the issue.
What else could it be?
Nagios includes its own embedded perl interpreter. Your plugin is probably not epn compliant.
You might want to disable it globally, or just disable it for your script. The bottom of that docs page shows you how to do this.
Basically, add
# nagios: -epn
on its own line somewhere within the first ten lines of your script. This should fix your problem.You could also make it compliant, but it's almost certainly not worth the trouble.
Some Perl scripts from the Nagios Exchange will try to include the
utils.pm
Perl module. You'll find a line like this somewhere in it:When installing Nagios on Debian, the default location of the
utils.pm
file is/usr/lib/nagios/plugins/utils.pm
. So theuse lib
directive should be:Executing the command from the command line most likely worked because you were in
/usr/lib/nagios/plugins/
, editing your plugin.Prefix the command with
/usr/bin/perl
.This solution is more of a workaround, it's probably not a good idea to do so but at least your plugin should work the same way it does when you launch it from the terminal.
NOTE: In my experience
# nagios -epn
works quite often, but sometimes it doesn't seem to be enough. I noticed that when this happens, the faulty plugins reports many warnings (when the script is invoked withperl -w
).