问题
I am getting the error (Return code of 255 is out of bounds) on the http://localhost/nagios
But when I run the command from the shell, it runs fine
回答1:
If you're using NRPE and receiving a 'NRPE: Unable to read output' error it is because the NRPE daemon is not returning text data. The Nagios core depends on NRPE daemons to return a string that summarizes the results of the checks. For instance, for a check result that is returning a healthy status, it may look like the former whereas an unhealthy status would be displayed the the latter.
OK - load average: 1.56, 1.37, 1.29
CRITICAL - load average: 16.59, 19.41, 21.96
If NRPE were to return something like this:
FOO: bar
You're going to get a 'NRPE: Unable to read output' error because FOO is not one of Nagios's known result states. Run the remote NRPE command by running something like this (depending on your directories and checks):
libexec/check_nrpe -n -H localhost -c check_load
That should return OK, WARNING, CRITICAL, or UNKNOWN. Anything else will cause that error.
回答2:
A Nagios check should return 0, 1, 2 or 3:
- 0: OK
- 1: Warning
- 2: Critical
- 3: Unknown
An exit status of 255 is perfectly valid when you run the command manually, so bash won't complain. You can check the exit status of the command in the variable $?
after the command has run with:
echo $?
回答3:
For posterity, I'll add something for anyone who runs into this. Two things you need to check:
Check that the server doing the checks has permission to access the client it is testing In this case, localhost is the server (& the client). Nevertheless, NRPE on the client needs to explicitly grant permission to the server going to check it. If your NRPE is wrapped by the xinetd service, you need to add the nagios server to the only_from directive on the client conf file(/etc/xinetd.d/nrpe)
only_from = 127.0.0.1 NagiosServerHostName
NagiosServerHostName needs to be in /etc/hosts. Alternatively, put the NagiosServerIP
Check that the firewall isn't blocking your checks. NRPE by default runs on port 5666; ensure that that port is allowed
回答4:
You mention that you are calling the check command via nrpe. If you are using a check command which returns multi-line output you must use a recent version of nrpe that also supports multi-line output otherwise the check_nrpe script will not be able to parse the output.
回答5:
i had this error, it turned out the plugin writes to a location where it has no rights to write so i just chmod 777 that location and it worked
回答6:
My guess would be that your check_nrpe command is not properly set up in the Nagios configuration file. If you open the Commands.cfg file in /usr/local/nagios/etc/objects/ and double check that the command setup you have there is exactly the same as the setup you are using in your bash script. The command I have setup is:
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
And my service definition:
define service{
use generic-service
host_name ********
service_description HTTP Requests
contact_groups localadmin
check_command check_nrpe!check_vbs_sample
}
Also I find it easier to use a simple script, for exampe a batch script that just returns OK to test its working first.
回答7:
As several posters have said, if Nagios doesn't receive the response it expects from the script, it will generate this error.
There are lots of ways in which a script can generate an error. To find out what the error is, update your command definition so that Standard Error from the script is written to a log file:
command_line $USER1$/check_nrpe -H $ARG1$ -c $ARG2$ 2> /tmp/error.log
回答8:
I just had the same error and it had to do with the firewall being on in the remote client.
回答9:
Hope this helps, in my case the issue was an ssh issue. To resolve the return code error I remoted into the remote servers as the nagios user from the server where nagios is being used (master node if you will). Allowing an entry into the known_hosts file from the master nagios server.
来源:https://stackoverflow.com/questions/1461826/nagios-return-code-of-255-is-out-of-bounds