Return code of 4 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.
pintu
Posts: 27
Joined: Fri Jun 09, 2017 6:33 am

Return code of 4 is out of bounds

Post by pintu »

I know that there are many inquiries regarding :
(Return code of 4 is out of bounds : /usr/local/nagios/libexec/check_port.pl -p <port> -h <host> (-c <critical> -w <warning> -v)))
but I haven't found an answer, so I would like to ask.

In my Nagios configuration, I have set up:
define service{
use none
host_name TEST
service_description Port 80
check_command check_port.pl! -p 80 -h www.google.com '-w 1 -c 2 -v'
max_check_attempts 1
check_interval 1
retry_interval 1
}
And I'm getting a return:
(Return code of 4 is out of bounds : /usr/local/nagios/libexec/check_port.pl -p <port> -h <host> (-c <critical> -w <warning> -v)))

I am running it from the command line.
./check_port.pl -p 80 -h google.pl -w 1000.0,80% -c 2000.0,100% -v

I get:
PORT 80 OK: google.pl/80 is responding
Which ties to the following command:

Code: Select all

define command{
        command_name    check_port.pl
        command_line    $USER1$/check_port.pl -p $ARG1$ -h $HOSTADDRESS$
        }
Where is the problem?
kg2857
Posts: 237
Joined: Wed Apr 12, 2023 5:48 pm

Re: Return code of 4 is out of bounds

Post by kg2857 »

From the docs the -c and -w want integer values in seconds. A return value of 4 isn't in the range of 0-3 that are valid. The output described suggests a syntax issue.
pintu
Posts: 27
Joined: Fri Jun 09, 2017 6:33 am

Re: Return code of 4 is out of bounds

Post by pintu »

Can you write exactly about which syntax you have in mind?
I tried:

Code: Select all

define command{
        command_name    check_port.pl
        command_line    $USER1$/check_port.pl -p $ARG1$ -h $ARG2$ -w $ARG3$ -c $ARG4$ -v
        }

Code: Select all

define command{
        command_name    check_port.pl
        command_line    $USER1$/check_port.pl -p $ARG1$ -h $HOSTADDRESS$ -w $ARG2$ -c $ARG3$ -v
        }
check_command check_port.pl! -p 80 -h www.google.com '-c 1 -w 2 -v'
pintu
Posts: 27
Joined: Fri Jun 09, 2017 6:33 am

Re: Return code of 4 is out of bounds

Post by pintu »

any idea? someone can help?
pintu
Posts: 27
Joined: Fri Jun 09, 2017 6:33 am

Re: Return code of 4 is out of bounds

Post by pintu »

Can anyone suggest anything?
kg2857
Posts: 237
Joined: Wed Apr 12, 2023 5:48 pm

Re: Return code of 4 is out of bounds

Post by kg2857 »

Read the script and find out why it doesn't like the syntax you use, which we see is the issue--syntax in case it was missed...
dameonmills
Posts: 1
Joined: Tue Aug 08, 2023 11:12 pm

Re: Return code of 4 is out of bounds

Post by dameonmills »

Can you point out where you think you missed it?
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Return code of 4 is out of bounds

Post by eloyd »

You say you're running from the command line, but I'll assume you're running as root. What happens if you run as Nagios user:

Code: Select all

# su - nagios
$ ./check_port.pl -p 80 -h google.pl -w 1000.0,80% -c 2000.0,100% -v
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
pintu
Posts: 27
Joined: Fri Jun 09, 2017 6:33 am

Re: Return code of 4 is out of bounds

Post by pintu »

$ ./check_port.pl -p 80 -h google.pl -w 1000.0,80% -c 2000.0,100% -v
-sh: 1: ./check_port.pl: not found
From this level, I cannot go to the location: /usr/local/nagios/libexec/ and that's why it wasn't found.
kg2857
Posts: 237
Joined: Wed Apr 12, 2023 5:48 pm

Re: Return code of 4 is out of bounds

Post by kg2857 »

The . translates to the current dir so you have to be in the dir containing the script to run it.

I'm not sure I like the quotes around some of the args in the following, but I could be full of crap...
check_command check_port.pl! -p 80 -h www.google.com '-w 1 -c 2 -v'

Naming a command after the script could cause confusion so I'd name the command check_port.
Post Reply