Plugin check_ntp_peer Return code of 126 is 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.
Locked
intern_nagios
Posts: 11
Joined: Wed May 27, 2015 3:39 pm

Plugin check_ntp_peer Return code of 126 is out of bounds

Post by intern_nagios »

Hi there,

I'm trying to check the NTP status and offset of my NTP servers in Nagios. When I manually ran the command, I did get the result I was looking for:

Code: Select all

./check_ntp_peer -H **** -w .5 -c 1
NTP OK: Offset 0.001174 secs|offset=0.001174s;0.500000;1.000000;
As soon I configured Nagios to ran the plugin I received the "(Return code of 126 is out of bounds - plugin may not be executable)" error.

- the plugin does have the following rights: -rwxr-xr-x. 1 nagios nagios 172921 May 13 14:59 check_ntp_peer

I'll show the command definition:

Commands.cfg

Code: Select all

define command{
        command_name    check_ntp
        command_line    /usr/local/nagios/libexec/check_ntp_peer -H $HOSTADDRESS$ -w .5 -c 1
       }
The most of my plugins are installed at /usr/lib64/nagios/plugins so that's where $USER1$ is pointing at. I did create a $USER2$ to /usr/local/nagios/libexec but that did not work either.

Do you guys know what I did wrong? Thanks in advance.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Plugin check_ntp_peer Return code of 126 is out of bound

Post by tmcdonald »

When running it from the CLI, are you running it as root or as nagios? Make sure the nagios user is used for testing, since that is what will ultimately end up being used.
Former Nagios employee
intern_nagios
Posts: 11
Joined: Wed May 27, 2015 3:39 pm

Re: Plugin check_ntp_peer Return code of 126 is out of bound

Post by intern_nagios »

Thanks. I tried the following and I guess you were right.

Code: Select all

#runuser -l nagios /usr/local/nagios/libexec/check_ntp_peer
/usr/local/nagios/libexec/check_ntp_peer: /usr/local/nagios/libexec/check_ntp_peer: cannot execute binary file
To make sure I did use the correct command, I check also if I can run with root, as in

Code: Select all

runuser -l nagios /usr/local/nagios/libexec/check_ntp_peer
Unfortunately, that did not work either.

So, I checked the permissions and saw the following:

Code: Select all

#ll | grep ntp_peer
-rwxr-xr-x. 1 nagios nagios 172921 May 13 14:59 check_ntp_peer
I think I use the wrong file or something like that? Does anyone have a clue?
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Plugin check_ntp_peer Return code of 126 is out of bound

Post by tgriep »

A couple of things you can do.
You can move the plugin check_ntp_peer to your other folder /usr/lib64/nagios/plugins and run it from there.
Or you will need to make sure the nagios user has the permissions setup correctly on the folders /usr/local/nagios and /use/local/nagios/libexec
Be sure to check out our Knowledgebase for helpful articles and solutions!
intern_nagios
Posts: 11
Joined: Wed May 27, 2015 3:39 pm

Re: Plugin check_ntp_peer Return code of 126 is out of bound

Post by intern_nagios »

Hi tgriep,

Thanks for the help.
I already tried your first suggestion, to move/copy the check_ntp_peer file to the /usr/lib64/nagios/plugins/ folder, no succes, same error.
I'll check and compare the permissions on the folders and change them if there are differences. Keep you posted after that.

Thanks!
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Plugin check_ntp_peer Return code of 126 is out of bound

Post by tgriep »

Another thing to try is to set both the owner and group to root of the check_ntp_peer check.
Be sure to check out our Knowledgebase for helpful articles and solutions!
intern_nagios
Posts: 11
Joined: Wed May 27, 2015 3:39 pm

Re: Plugin check_ntp_peer Return code of 126 is out of bound

Post by intern_nagios »

I solved the problem, I used the restorecon command and after that the plugin worked immediately.

Thanks guys!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Plugin check_ntp_peer Return code of 126 is out of bound

Post by tmcdonald »

I'll be closing this thread now, but feel free to open another if you need anything in the future!
Former Nagios employee
Locked