Perl, die and " Return code of 127"

I was beating my head against the wall on this one and figured a post of this may save someone else some pain in the future…

I had a Perl check that worked perfectly from the command line, but I was getting the " Return code of 127" from Nagios. I went over my configurations repeatedly and could not find the issue.

I eventually figured out Nagios did not like my Perl “die” statements. See I was sending strings to my stderr like
abc=cat $file or die “no such file\n”;

these kind of script entries will give you the 127 error

I fixed this by changing them to someting like this

abc=cat $file or &giveerror;

sub giveerror {
print “no such file.\n”;
exit 2;
}

Lesson Learned:
Nagios just wants stdout and a return code and not text to stderr.

-Brian :slight_smile: