Page 1 of 2

126 Out of bounds

Posted: Tue Feb 11, 2014 10:00 am
by dario.quiroz
Hi, I made my own script but it returns 126 out of bounds.
I read the documentation of nagios so:

It returns: [1392130212] Warning: Return code of 126 for check of service 'Link Status' on host 'florestal-ptp600-sistemas' was out of bounds.Make sure the plugin you're trying to run is executable.

The script is executable: -rwxr-xr-x. 1 root root 35 Feb 11 11:39 check_link

The script is in the correct path: /usr/lib/nagios/plugins

The script is running as nagios user: [root@Nagios-Cacti plugins]# su nagios
bash-4.1$ ./check_link
test-ok

I changed the content of the script to something simple, only to discard any mistake on it: #!/bin/bash; echo "test-ok"; exit 0

The return is ok:
bash-4.1$ ./check_link
test-ok
bash-4.1$ echo $?
0


What else can I do to run the script ok???
Thanks in advance!!!

Re: 126 Out of bounds

Posted: Tue Feb 11, 2014 11:16 am
by slansing
Can you provide the script in an attachment? Are you doing anything in the script that expects a certain user level? If you are executing it as nagios, or apache, I suggest you change it's permissions accordingly.

Re: 126 Out of bounds

Posted: Tue Feb 11, 2014 3:04 pm
by dario.quiroz
Thanks for the help!!!

The script is this:
#!/bin/bash
echo "test-ok"
exit 0

Re: 126 Out of bounds

Posted: Tue Feb 11, 2014 5:42 pm
by lmiltchev
Can you post the service and the command definitions?

Re: 126 Out of bounds

Posted: Wed Feb 12, 2014 6:36 am
by dario.quiroz
Log: [1392204630] Warning: Return code of 126 for check of service 'Link Status' on host 'florestal-ptp600-sistemas' was out of bounds.Make sure the plugin you're trying to run is executable.

host.cfg:
define service{
use generic-service
host_name florestal-ptp600-sistemas
service_description Link Status
check_command check_link
}


commands.cfg:
define command{
command_name check_link
command_line $USER1$/check_link
}



[root@Nagios-Cacti plugins]# ls -l check_link
-rwxr-xr-x. 1 root root 34 Feb 11 11:52 check_link


[root@Nagios-Cacti plugins]# cat check_link
#!/bin/bash
echo "test-ok"
exit 0

This is not the real plugin, but I clean all the parameters and contents of the real script only to find the problem.. When I can run this simple script, I'll try to put the definitive one.
Thanks in advance!!!!

Re: 126 Out of bounds

Posted: Wed Feb 12, 2014 12:00 pm
by slansing
Ohhhh, I think we were working under the assumption you were running this locally, if that check_link plugin is only doing what you showed us, that command definition will definitely not work, you need something to execute the plugin remotely. Such as NRPE. http://nagios.sourceforge.net/docs/nrpe/NRPE.pdf

You will then need to set up a command definition on the nagios server for check_nrpe, and use it to remotely execute that plugin of yours, once nrpe is installed on the remote host let us know.

Re: 126 Out of bounds

Posted: Wed Feb 12, 2014 1:55 pm
by dario.quiroz
Sorry but is locally!!

Re: 126 Out of bounds

Posted: Wed Feb 12, 2014 2:10 pm
by dario.quiroz
The script is running locally!... If I'm not wrong, the script runs and returns 0 (exit 0).. nothing more than this.. is this ok? but anyway, why the Nagios say it's out of bound? is not executable?

Re: 126 Out of bounds

Posted: Wed Feb 12, 2014 2:10 pm
by slansing
Okay, if it is local why do you want to have it set up with a remote host? You should be assigning your service the "localhost" host like so:

Code: Select all

define service{
use generic-service
host_name localhost
service_description Link Status
check_command check_link
}
Do you have the plugin in /usr/local/nagios/libexec/ or what you have $USER1$ pointing to? Yes, it must be executable. You might want to try switching it's user + group to nagios:nagios, or what you have set in the plugins directory for your other plugins.

Re: 126 Out of bounds

Posted: Wed Feb 12, 2014 2:33 pm
by dario.quiroz
All the plugins have equal permissions!! and yes, they are in /usr/lib/nagios/plugins:

-rwxr-xr-x. 1 root root 38 Feb 12 09:40 check_link
-rwxr-xr-x. 1 root root 636 Feb 12 09:33 check_link.bk
-rwxr-xr-x. 1 root root 3871 Oct 17 08:43 check_linux_raid
-rwxr-xr-x. 1 root root 38988 Oct 17 08:43 check_load
-rwxr-xr-x. 1 root root 6020 Oct 17 08:43 check_log
.
.
.
.
-rwxr-xr-x. 1 root root 51488 Oct 17 08:43 check_ping
-rwxr-xr-x. 1 root root 89276 Oct 17 08:43 check_snmp


define service{
use generic-service
# host_name florestal-ptp600-sistemas
host_name localhost
service_description Link Status
check_command check_link
}


[1392233318] Warning: Return code of 126 for check of service 'Link Status' on host 'localhost' was out of bounds.Make sure the plugin you're trying to run is executable.
[1392233318] SERVICE ALERT: localhost;Link Status;CRITICAL;SOFT;1;(Return code of 126 is out of bounds - plugin may not be executable)