Return code of 126 is out of bounds - plugin may not be exec

I suck with Linux, and I’m not a pro at Nagios. I’m trying to install a plugin to check the LDAP on one of my domain controllers.

So I download this script, and copy over the various information for the commands.cfg and service check stuff.

Well when I start it up in Nagios I get the error…

Return code of 126 is out of bounds - plugin may not be executable

So I do some research and try to run the actual script on the Terminal.

When I run the command I found that I actually need some Net::LDAP::Util. So I managed to get that installed, but it still will not work.

When I run the script in the terminal I get…

/usr/local/nagios/libexec/check_ldap.pl: line11: use: command not found
/usr/local/nagios/libexec/check_ldap.pl: line12: use: command not found
/usr/local/nagios/libexec/check_ldap.pl: line13: use: command not found
/usr/local/nagios/libexec/check_ldap.pl: line14: use: Syntax error near unexpected token (' /usr/local/nagios/libexec/check_ldap.pl: line 14: use Net::LDAP::Util qw(ldap_error_text);`

I cannot find documentation anywhere that even talks about the basics of installing plugins. And most plugins I find on the internet are lacking actual details on what’s required or how to install them, which is difficult to a non-expert.

I don’t mind doing some reading to find out how to make this work, but some guidance would be awesome.

EDIT: Here is where I got the plugin from…

s23.org/wiki/Nagios/checks/ldap

the script you have has some blank spaces in the first two columns.
delete them on the FIRST line…
it has to start with: # there have to be NO BLANKs in front of it. or it won’t load the perl interpreter