- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
作为 IT 项目的一部分,我使用了 Nagios。为了获得温度传感器的值,我创建了一个 python 插件,它将读取数据库中的值,并在屏幕上打印出来。
问题是当我要监控基于这个插件的服务时,在Centreon web界面显示为CRITICAL错误“(Return code 127 is out of bounds ) 插件可能丢失了
"。
这是我的安装总结:
Nagios + NDOutils (+Centreon Web Interface) 在 Debian 7.5 上安装: http://fr.scribd.com/doc/239973292/1-Installation-Manuelle-de-Nagios-Centreon-Debian#scribd
我创建了一个 python 插件“cigne_plugin.py
”,它将读取数据库中的值,并打印在屏幕上。
在 /usr/local/nagios/libexec
cigne_python.py
”在文件/usr/local/nagios/etc/resource.cfg
中,$USER1$
宏定义在/usr/local/nagios/libexec
在 /usr/local/nagios/etc/checkcommands.cfg
中,我添加了这些行:
define command{
command_name arduino_temp_sensor
command_line $USER1$/cigne_plugin.py
}
在 /usr/local/nagios/etc/objects/commands.cfg
中,我添加了以下行:
define command{
command_name arduino_temp_sensor
command_line $USER1$/cigne_plugin.py
}
在 /usr/local/nagios/etc/objects/localhost.cfg
中:
define service{
use local-service
host_name localhost
service_description Arduino Temp
check_command arduino_temp_sensor
notification_enabled 0
}
在 Centreon Web 界面(配置 -> 命令)中添加命令“arduino_temp_sensor
”
在 Centreon Web 界面(配置 -> 服务)中添加服务“Arduino Temp”
检查文件权限
检查脚本是否可以执行
检查文件所有者
检查用户和组
在 /usr/local/nagios/etc/services.cfg
中,我的服务是为“本地主机”创建的
我尝试使用注释所有代码的插件版本,它只返回“sys.exit(2)
”,问题不在代码中。
最佳答案
让我们尝试构建 test_wrapper.sh shell 脚本,看看是否存在一些更普遍的问题,或者它是否只是与 python 隔离。
[joe@joeyoung.io libexec]# pwd
/usr/local/nagios/libexec
[joe@joeyoung.io libexec]# cat <<EOF >> test_wrapper.sh
> #!/bin/sh
> echo "OK"
> exit 0
> EOF
[joe@joeyoung.io libexec]# cat test_wrapper.sh
#!/bin/sh
echo "OK"
exit 0
[joe@joeyoung.io libexec]# ls -al test_wrapper.sh
-rw-r--r-- 1 joe joe 27 Aug 6 15:48 test_wrapper.sh
[joe@joeyoung.io libexec]# chmod a+x test_wrapper.sh
[joe@joeyoung.io libexec]# ls -al test_wrapper.sh
-rwxr-xr-x 1 joe joe 27 Aug 6 15:48 test_wrapper.sh
[joe@joeyoung.io libexec]# ./test_wrapper.sh
OK
“OK”表示输出正常。
[joe@joeyoung.io libexec]# echo $?
0
0的Return Code表示返回码正常。
现在让我们构建一个简单的 test_wrapper.py 来消除 python 代码内容的任何问题。
[joe@joeyoung.io libexec]# cat <<EOF >> test_wrapper.py
> import sys
>
> def main():
> print "OK"
> sys.exit(0)
>
> if __name__ == '__main__':
> main()
> EOF
[joe@joeyoung.io libexec]# cat test_wrapper.py
import sys
def main():
print "OK"
sys.exit(0)
if __name__ == '__main__':
main()
[joe@joeyoung.io libexec]# ls -al test_wrapper.py
-rw-r--r-- 1 joe joe 124 Aug 6 15:58 test_wrapper.py
[joe@joeyoung.io libexec]# chmod a+x test_wrapper.py
[joe@joeyoung.io libexec]# ls -al test_wrapper.py
-rwxr-xr-x 1 joe joe 124 Aug 6 15:58 test_wrapper.py
[joe@joeyoung.io libexec]# python test_wrapper.py
OK
“OK”表示输出正常。
[joe@joeyoung.io libexec]# echo $?
0
0的Return Code表示返回码正常。
最后让我们添加命令和服务定义,以便我们可以通过 Nagios 网络界面对其进行测试。
修改/usr/local/nagios/etc/objects/commands.cfg
注意: 我们只修改一个 commands.cfg
文件,这样我们就没有重复的命令定义来混淆 Nagios。我们暂时忽略 checkcommands.cfg
。
添加:
define command {
command_name sh_test_wrapper
command_line $USER1$/test_wrapper.sh
register 1
}
define command {
command_name python_test_wrapper
command_line /usr/bin/python $USER1$/test_wrapper.py
register 1
}
修改/usr/local/nagios/etc/objects/localhost.cfg
添加:
define service{
use local-service
host_name localhost
service_description sh test wrapper
check_command sh_test_wrapper
notification_enabled 0
register 1
}
define service{
use local-service
host_name localhost
service_description python test wrapper
check_command python_test_wrapper
notification_enabled 0
register 1
}
让我们验证配置文件
[joe@joeyoung.io libexec]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
然后重新启动 Nagios。
[joe@joeyoung.io libexec]# service nagios restart
让我们看看这些非常基本的检查是否有效,看看我们是否可以进一步缩小问题的范围。
关于python - Nagios/Centreon 错误 : Return code 127 is out of bounds : Plugin may be missing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31852379/
在许多在线资源中,可以找到“内存”、“带宽”、“延迟”绑定(bind)内核的不同用法。在我看来,作者有时会使用他们自己对这些术语的定义,我认为这对某人做出明确区分非常有益。 据我了解:带宽绑定(bin
FIFO、LIFO 和LC Branch and Bound 有什么区别? 最佳答案 Branch & Bound 通过使用估计边界来限制可能解决方案的数量来发现完整搜索空间内的分支。不同的类型(FI
我有一个网页,其中有一些 Kendo 控件(例如下拉菜单和按钮)可以正常工作,但是添加Grid 会导致问题。 @(Html.Kendo().Grid(Model).Name("grid").Colu
术语“CPU 限制”和“I/O 限制”是什么意思? 最佳答案 这非常直观: 如果 CPU 更快,程序就会运行得更快,即程序的大部分时间只是使用 CPU(进行计算),则该程序是 CPU 密集型。 计算
我在以下代码段中遇到问题并发出警告,希望您能帮助我: fprintf (fp, "%dd%d+%d ", pMobIndex->mana[DICE_NUMBER], DICE_NUMBER 在我
swift 2 let gap = CGFloat(randomInRange(StackGapMinWidth...maxGap)) Missing argument label 'range:'
swift 2 let gap = CGFloat(randomInRange(StackGapMinWidth...maxGap)) Missing argument label 'range:'
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 关闭 6 年前。 这个问题是由于打字错误或无法再重现的问题引起的。虽然类似的问题可能是on-topic在
我想在gcc8.2下启用数组边界检查,这样可以帮助在编译期间检查数组下标是否越界,它可能会给出如下警告:数组下标高于数组边界 [-Warray-bounds] 我使用 coliru 做了一个演示: #
我只是想知道在 Apple API 中的什么地方定义了变量“bounds.minX”、“bounds.maxX”?我查看了“UIView”和“CGRect”文档,但似乎找不到它? 最佳答案 它包含在"
我想覆盖整个屏幕。我想将其框架设置为覆盖整个屏幕。浏览堆栈溢出时,我发现了这两种不同的设置 View 框架以覆盖屏幕的方法: [UIScreen mainScreen].bounds [UIApplc
在协程中执行 IO 绑定(bind)函数(例如,从后端请求数据)给了我一个优势,即在请求结果可用之前暂停它的执行,对吗?但是,受 CPU 限制的函数(例如,解析一个巨大的文本文件)不会“等待”任何东西
public class ChampionsLeague> extends League{ ... 如何创建此类的实例? ChampionsLeague league = new ChampionsL
我遇到了以下问题: 我有这些类和接口(interface)定义 public abstract class ViewModelRefreshPostListFragment> extends
我注意到在使用 (Swift 4.0) 的 IOS X 代码中,我至少可以通过以下两种方式请求 View 的高度 V: V.bounds.size.height 和... V.bounds.heigh
swift 中 bounds.size.width 和 bounds.width 有什么区别?他们会返回同样的东西吗?谢谢! 最佳答案 bounds 是 UIView 的 CGRect 结构属性,其中
在我看来不可能包含 Integer.MAX_VALUE和Long.MAX_VALUE创建 IntStream 时尽可能使用随机值或LongStream使用 java.util.Random 的边界类。
我有二叉树类: public class BinaryTree> extends AbstractTree { protected TreeNode root;
我最近做了并更新了我的 Xamarin iOS 项目,我曾经能够调用以下代码来检索屏幕宽度和高度: if (orientation == UIInterfaceOrientation.Landscap
我仍然不明白为什么我收到这个警告 array subscript is above array bounds [-Warray-bounds] 对于一个小的 C 代码如下: #include #in
我是一名优秀的程序员,十分优秀!