Check_http_xpath.pl - Return code of 255 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
spacemanspiff
Posts: 22
Joined: Mon Mar 24, 2014 3:53 pm

Check_http_xpath.pl - Return code of 255 is out of bounds

Post by spacemanspiff »

I've a pile of fibre RAIDs that provide many environmental and performance variables via XML. I can usually parse this successfully using check_http_xpath.pl. However, currently despite all the green OK statuses, I'm getting "Return code of 255 is out of bounds."

The confusion arises at the command line:

Code: Select all

$ echo $?
0
...which means the return code is 0. Is Nagios just confused here?

Here's the command as I run it at the command line:

Code: Select all

# perl /usr/local/nagios/libexec/check_http_xpath.pl -I 10.10.10.10 -l admin -a password -u /xml.asp -c '/status/perf_status/array[1]/load_percent<=90'
OK: load_percent=81|/status/perf_status/array[1]/load_percent=81
Here's what shows up in the log file:

Code: Select all

Aug  5 18:03:39 monag nagios: Warning: Return code of 255 for check of service 'Array 1 Load' on host 'raid1' was out of bounds.
Aug  5 18:03:39 monag nagios: SERVICE ALERT: raid1;Array 1 Load;UNKNOWN;HARD;3;(Return code of 255 is out of bounds)
Here's the config for the command:

Code: Select all

# Check Array Load
define command{
command_name check_raid_array_load
command_line /usr/local/nagios/libexec/check_http_xpath.pl -H $HOSTADDRESS$ -l admin -a $ARG2$ -u /admin/xml.asp -c '/status/perf_status/array[`'$ARG3$`']/load_percent<=90' -w '/status/perf_status/array[`'$ARG3$`']/load_percent<=75'
}
I've tried the command with $ARG3$ printed as [`'$ARG3$'`] and ['$ARG3$'], but that doesn't make a difference. The confusing thing is that this did work the last time I tried it.

Here's the service definition:

Code: Select all

define service{
        use                             generic-service ; defined in generic
        host_name                       raid1
        service_description             Array 1 Load ; give description
        check_command                   check_raid_array_load!password!1 ; defined commandline
        normal_check_interval           10 ; useful time check
}

Any ideas here?

This is on a freshly installed Nagios VM. CentOS 6.5, Nagios core 4.0.5.

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

Re: Check_http_xpath.pl - Return code of 255 is out of bound

Post by tmcdonald »

Two things I see wrong:

1.) You seem to have no $ARG1$, only $ARG2$ and $ARG3$ in your command_line entry. This is fine, you don't have to actually use all the args, but you also have only two arguments in your check_command entry, currently the password and (I'm guessing) the array index. You will need to adjust the $ARGX$ variables to match the actual number of args.

2.) You probably do not need quotes around the array index if the quotes were not present when running the command manually. Currently you have it set so you are trying to access array[''1''] (two single quotes on each side, not a double quote) or array['1'] when it should just nee array[1]
Former Nagios employee
spacemanspiff
Posts: 22
Joined: Mon Mar 24, 2014 3:53 pm

Re: Check_http_xpath.pl - Return code of 255 is out of bound

Post by spacemanspiff »

tmcdonald wrote:Two things I see wrong:

1.) You seem to have no $ARG1$, only $ARG2$ and $ARG3$ in your command_line entry. This is fine, you don't have to actually use all the args, but you also have only two arguments in your check_command entry, currently the password and (I'm guessing) the array index. You will need to adjust the $ARGX$ variables to match the actual number of args.
I didn't think much about this. The reason for that is the original command - which did work - was this:

Code: Select all

# Check Array 1 Load
define command{
command_name check_array_1_load
command_line /usr/local/nagios/libexec/check_http_xpath.pl -H $HOSTADDRESS$ -l admin -a $ARG2$ -u /admin/xml.asp -c '/status/perf_status/array[1]/load_percent<=90' -w'/status/perf_status/array[1]/load_percent<=75'
}
Therefore my assumption was $HOSTADDRESS$ was in fact the $ARG1$ value. But that doesn't resolve the fact that this above command works without the return code being out of bounds.
tmcdonald wrote:2.) You probably do not need quotes around the array index if the quotes were not present when running the command manually. Currently you have it set so you are trying to access array[''1''] (two single quotes on each side, not a double quote) or array['1'] when it should just nee array[1]
OK, thanks.



Modifying the commands worked. The successful command is:

Code: Select all

# Check Array Load
define command{
command_name check_array_load
command_line /usr/local/nagios/libexec/check_http_xpath.pl -H $HOSTADDRESS$ -l admin -a $ARG1$ -u /admin/xml.asp -c '/status/perf_status/array[$ARG2$]/load_percent<=90' -w'/status/perf_status/array[$ARG2$]/load_percent<=75'
}

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

Re: Check_http_xpath.pl - Return code of 255 is out of bound

Post by tmcdonald »

Glad I could help, spaceman. Closing this one up.
Former Nagios employee
Locked