警告:用于检查服务的返回代码 127 超出范围。确保您尝试运行的插件确实存在



我正在尝试为Nagios使用phanton-js插件: https://github.com/hggh/phantomjs-nagios

但是尽管我仔细检查了设置,但我还是得到了 "返回代码 127 越界:插件可能丢失">

插件文件存在于插件文件夹中:

# stat /usr/lib64/nagios/plugins/check_http_load_time.rb
File: `/usr/lib64/nagios/plugins/check_http_load_time.rb'
Size: 9108            Blocks: 24         IO Block: 4096   regular file
Device: fc01h/64513d    Inode: 275201      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)

我可以在本地向 nagios 用户执行它:

-bash-4.1$ whoami
nagios
-bash-4.1$ /usr/lib64/nagios/plugins/phantomjs-nagios/check_http_load_time.rb -u https://google.com -w 2 -c 3
OK: https://google.com load time: 0.43

这是在 checkmodels.cfg 文件中定义的

define command {
command_name    check_web_page_load_time
command_line    $USER1$/check_http_load_time.rb -u $ARG1$ -w $ARG2$ -c $ARG3$
}

这是服务定义

define service {
use                   generic-service
host_name             test_host
service_description   https://google.com web load time
check_command         check_web_page_load_time!https://google.com!2!3
contact_groups        support-emails
}

我已经重新启动了 nagios 并确认配置检查通过。

我错过了一些明显的东西吗?

编辑:

插件文件位于 2 个文件夹中:

/usr/lib64/nagios/plugins/check_http_load_time.rb

/usr/lib64/nagios/plugins/phantomjs-nagios/check_http_load_time.rb

这两个文件是相同的,都可以由 Nagios 用户成功执行,并且两个位置都不适用于命令定义。我尝试使用完整路径和 $USR 1$ 变量调用它,该变量指向所有其他插件所在的标准位置

/usr/lib64/nagios/plugins/

最终解决它。错误消息不是很有帮助,因为问题出在nagios用户的环境变量上。 原始脚本有以下 shebang:

#!/usr/bin/env ruby

将其更改为 ruby 二进制文件的实际位置后,脚本工作:

#!/usr/local/rvm/rubies/ruby-2.5.1/bin/ruby

仍然惊讶于它在 su's 对 Nagios 用户时有效。

最新更新