0

I have the following service defined in my host definition:

define service {
    use                  generic-service
    host_name            myhost.com
    service_description  swapcheck
    check_command        check_ssh_swap
}

and the following in the commands.cfg:

define command {
    command_name check_ssh_swap
    command_line /home/nagios/bin/check_by_ssh -p port -H ip -C "/home/nagios/bin/check_swap -w 20% -c 5%"
}

both cfg files are loaded into nagios on load. And nagios -v /etc/nagios/nagios.cfg does not give back any errors.

When i try to execute the command

/home/nagios/bin/check_by_ssh -p port -H ip -C "/home/nagios/bin/check_swap -w 20% -c 5%"

with the nagios user directly, it works without problems, and I get my results back, but when nagios itself runs a scheduled check I always get

Return code of 126 for check of host 'host' was out of bounds

What am I missing here? Obviously all the paths, the keys, etc. are correct, otherwise I wouldnt be able to execute it manually without any problems.

4

3 回答 3

0

显然,nagios 不喜欢绝对路径。我切换回 $USER1$/... 的路径,现在它可以工作了吗?

于 2013-09-14T22:25:08.737 回答
0

Nagios 的退出代码 126 应该意味着检查已找到,但它不可执行。也许您的脚本具有不正确的世界或其他权限,因此 Nagios 无法运行它,但您可以?

于 2013-09-16T21:28:17.280 回答
0

您的问题没有确定您使用的是哪个操作系统平台,但我猜CentOS。如果是这种情况,请检查是否SELinux启用并强制执行: #getenforce Enforcing

如果是这样,您有几个选择:

  1. 将您的脚本放在与其他工作脚本相同的位置;您可能需要这样做,restorecon以便您的脚本被适当地标记为目录
  2. 了解如何使用audit2allow添加到 Nagios 脚本的有效位置

我根本不推荐但仅出于完整性考虑而提及的另一种可能性是禁用SELinux. 除了快速测试之外,在执行此操作之前,请仔细考虑。

于 2015-09-08T10:06:24.897 回答