Nagios(返回码 255 超出范围)

发布于 2024-08-05 00:57:52 字数 148 浏览 8 评论 0原文

我在 http://localhost/nagios 上收到错误(返回代码 255 超出范围)

但是当我从 shell 运行命令,运行良好

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

药祭#氼 2024-08-12 00:57:52

如果您使用 NRPE 并收到“NRPE:无法读取输出”错误,这是因为 NRPE 守护程序未返回文本数据。 Nagios 核心依赖 NRPE 守护程序来返回总结检查结果的字符串。例如,对于返回健康状态的检查结果,它可能看起来像前者,而后者将显示不健康状态。

OK - load average: 1.56, 1.37, 1.29 
CRITICAL - load average: 16.59, 19.41, 21.96 

如果 NRPE 返回如下内容:

FOO: bar 

您将收到“NRPE:无法读取输出”错误,因为 FOO 不是 Nagios 的已知结果状态之一。通过运行类似以下内容来运行远程 NRPE 命令(取决于您的目录和检查):

libexec/check_nrpe -n -H localhost -c check_load

应该返回 OK、WARNING、CRITICAL 或 UNKNOWN。其他任何事情都会导致该错误。

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.

谜兔 2024-08-12 00:57:52

Nagios 检查应返回 0、1、2 或 3

  • 0:确定
  • 1:警告
  • 2:严重
  • 3:未知

当您手动运行命令时,退出状态 255 是完全有效的,因此 bash 不会抱怨。命令运行后,您可以在变量 $? 中检查命令的退出状态:

echo $? 

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 $? 
泛泛之交 2024-08-12 00:57:52

对于后代,我将为遇到此问题的任何人添加一些内容。
您需要检查两件事:

检查执行检查的服务器是否有权访问正在测试的客户端
在这种情况下,本地主机是服务器(和客户端)。然而,客户端上的 NRPE 需要显式授予服务器检查它的权限。如果您的 NRPE 被 xinetd 服务封装,则需要将 nagios 服务器添加到客户端 conf 文件 (/etc/xinetd.d/nrpe) 上的 only_from 指令中,

only_from       = 127.0.0.1 NagiosServerHostName

NagiosServerHostName 需要位于 /etc/hosts 中。或者,放置 NagiosServerIP

检查防火墙是否阻止您的检查。 NRPE 默认运行在端口 5666 上;确保该端口被允许

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

若沐 2024-08-12 00:57:52

您提到您正在通过 nrpe 调用检查命令。如果您使用返回多行输出的 check 命令,则必须使用也支持多行输出的最新版本的 nrpe,否则 check_nrpe 脚本将无法解析输出。

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.

音栖息无 2024-08-12 00:57:52

我遇到了这个错误,结果发现该插件写入了一个无权写入的位置,所以我只是 chmod 777 该位置并且它有效

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

热血少△年 2024-08-12 00:57:52

我的猜测是您的 check_nrpe 命令未在 Nagios 配置文件中正确设置。如果您打开 /usr/local/nagios/etc/objects/ 中的 Commands.cfg 文件,并仔细检查您的命令设置是否与您在 bash 脚本中使用的设置完全相同。我设置的命令是:

define command{
command_name    check_nrpe
command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

我的服务定义:

define service{
use         generic-service
host_name       ********
service_description HTTP Requests
contact_groups  localadmin
check_command       check_nrpe!check_vbs_sample
}

此外,我发现使用简单的脚本更容易,例如只返回“确定”以首先测试其工作的批处理脚本。

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.

世界等同你 2024-08-12 00:57:52

正如几位发帖者所说,如果 Nagios 没有收到它期望的脚本响应,它将生成此错误。

脚本产生错误的方式有很多种。要找出错误是什么,请更新命令定义,以便将脚本中的标准错误写入日志文件:

command_line $USER1$/check_nrpe -H $ARG1$ -c $ARG2$ 2> /tmp/error.log

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
梦与时光遇 2024-08-12 00:57:52

我刚刚遇到了同样的错误,这与远程客户端中打开的防火墙有关。

I just had the same error and it had to do with the firewall being on in the remote client.

你爱我像她 2024-08-12 00:57:52

希望这有帮助,就我而言,问题是 ssh 问题。为了解决返回代码错误,我以 nagios 用户身份从正在使用 nagios 的服务器(如果您愿意的话,主节点)远程访问远程服务器。允许从主 nagios 服务器进入known_hosts 文件。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文