126 Out of bounds

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
dario.quiroz
Posts: 7
Joined: Tue Feb 11, 2014 9:46 am

126 Out of bounds

Post 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!!!
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: 126 Out of bounds

Post 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.
dario.quiroz
Posts: 7
Joined: Tue Feb 11, 2014 9:46 am

Re: 126 Out of bounds

Post by dario.quiroz »

Thanks for the help!!!

The script is this:
#!/bin/bash
echo "test-ok"
exit 0
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: 126 Out of bounds

Post by lmiltchev »

Can you post the service and the command definitions?
Be sure to check out our Knowledgebase for helpful articles and solutions!
dario.quiroz
Posts: 7
Joined: Tue Feb 11, 2014 9:46 am

Re: 126 Out of bounds

Post 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!!!!
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: 126 Out of bounds

Post 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.
dario.quiroz
Posts: 7
Joined: Tue Feb 11, 2014 9:46 am

Re: 126 Out of bounds

Post by dario.quiroz »

Sorry but is locally!!
dario.quiroz
Posts: 7
Joined: Tue Feb 11, 2014 9:46 am

Re: 126 Out of bounds

Post 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?
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: 126 Out of bounds

Post 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.
dario.quiroz
Posts: 7
Joined: Tue Feb 11, 2014 9:46 am

Re: 126 Out of bounds

Post 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)
Locked