我如何获得一个自定义Nagios插件与NRPE一起使用? [英] How do I get a custom Nagios plugin to work with NRPE?

查看:132
本文介绍了我如何获得一个自定义Nagios插件与NRPE一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个没有互联网接入的系统,我想安装一些Nagios监控服务/插件。我安装了NRPE(Nagios Remote Plugin Executor),我可以看到它中定义的命令,如 check_users check_load check_zombie_procs 等。

 命令[check_users] = / usr / lib / nagios / plugins / check_users -w 5 -c 10 
命令[check_load] = / usr / lib / nagios / plugins / check_load -w 15,10,5 -c 30,25,20
。 ..

我可以像这样运行命令:

  / usr / local / nagios / libexec / check_nrpe -H 127.0.0.1 -c check_load 

这会产生如下输出:

 确定 - 加载平均值:0.01,0.13 ,0.12 | load1 = 0.010; 15.000; 30.000; 0; load5 = 0.130; 10.000; 25.000; 0; load15 = 0.120; 5.000; 20.000; 0; 

 警告 - 每个CPU的平均负载:0.06,0.07,0.07 | load1 = 0.059; 0.150; 0.300; 0; load5 = 0.069; 0.100; 0.250; 0; load15 = 0.073; 0.050; 0.200; 0; 

现在,我想定义/配置/安装一些更多的服务来监视。我在这里找到了一系列服务 。所以说,我想使用这里定义的服务,叫做 check_hadoop_namenode.pl 。我如何使它与NRPE一起工作?



我试着将文件 check_hadoop_namenode.pl 复制到同一个目录中其中存储其他NRPE服务,即 / usr / lib / nagios / plugins 。但它不起作用:
$ b $ p $ / usr / local / nagios / libexec / check_nrpe -H 127.0.0.1 -c check_hadoop_namenode.pl



我认为这可能很明显,因为该目录中的所有其他服务都是二进制文件,所以我需要一个二进制文件 check_hadoop_namenode .pl 文件。我如何为它制作二进制文件?



我尝试根据链接中的描述安装插件。但它只是试图安装一些软件包的依赖关系,并且因为无法访问互联网而引发错误(我的系统没有互联网访问权限,就像我之前所说的那样)。即使我在另一个系统中手动安装这些依赖关系并将它们复制到目标系统,该错误依然存在。

  $<在另一个系统中系统与互联网接入> 
mkdir〜/ repos
git clone https://github.com/harisekhon/nagios-plugins
cd nagios-plugins
sudo nano Makefile

#将'yum install'替换为'yumdownloader --resolv --destdir〜/ repos /'
#将'pip install'替换为'pip download -d〜/ repos /'

这下载了安装插件所需的43个依赖关系(以及依赖关系的依赖关系等)。



我如何得到它的工作?

解决方案

check_users nrpe.cfg中定义了c>, check_load check_zombie_procs code>文件。默认位置是 /usr/local/nagios/etc/nrpe.cfg /etc/nagios/nrpe.cfg 。在我阅读时,您已经找到该文件,因此您可以转到下一步。



把这样的东西放到 nrpe.cfg

 命令[check_hadoop_namenode] = / path / to / your / custom / script / check_hadoop_namenode.pl -optional -arguments 

然后您需要重新启动客户端上的NRPE deamon服务。像 service nrpe restart
这些自定义脚本并不一定是二进制文件,甚至可以使用简单的bash脚本。



最后,您可以从Nagios服务器或本地NRPE deamon调用 check_hadoop_namenode 命令: / usr / local / nagios / libexec / check_nrpe -H 127.0.0.1 -c check_hadoop_namenode


I have a system with no internet access where I want to install some Nagios monitoring services/plugins. I installed NRPE (Nagios Remote Plugin Executor), and I can see commands defined in it, like check_users, check_load, check_zombie_procs, etc.

command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
...

I am able to run the commands like so:

/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_load

This produces an output like:

OK - load average: 0.01, 0.13, 0.12|load1=0.010;15.000;30.000;0; load5=0.130;10.000;25.000;0; load15=0.120;5.000;20.000;0;

or

WARNING – load average per CPU: 0.06, 0.07, 0.07|load1=0.059;0.150;0.300;0; load5=0.069;0.100;0.250;0; load15=0.073;0.050;0.200;0;

Now, I want to define/configure/install some more services to monitor. I found a collection of services here. So, say, I want to use the service defined here called check_hadoop_namenode.pl. How do I get it to work with NRPE?

I tried copying the file check_hadoop_namenode.pl into the same directory where other NRPE services are stored, i.e., /usr/lib/nagios/plugins. But it doesn't work:

$ /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_hadoop_namenode.pl

I figured this might be obvious because all other services in that directory are binaries, so I need a binary for check_hadoop_namenode.pl file as well. How do I make the binary for it?

I tried installing the plugins according to the description in the link. But it just tries to install some package dependencies, and throws error as it cannot access the internet (my system has no internet access, like I stated before). This error persists even when I install these dependencies manually in another system and copy them to the target system.

$ <In another system with internet access>
mkdir ~/repos
git clone https://github.com/harisekhon/nagios-plugins 
cd nagios-plugins 
sudo nano Makefile

# replace 'yum install' with 'yumdownloader --resolv --destdir ~/repos/'
# replace 'pip install' with 'pip download -d ~/repos/'

This downloaded 43 dependencies (and dependencies of dependencies, and so on) required to install the plugins.

How do I get it to work?

解决方案

check_users, check_load or check_zombie_procs are defined on the client side in nrpe.cfg file. Default location are /usr/local/nagios/etc/nrpe.cfg or /etc/nagios/nrpe.cfg. As I read, you already found that file, so you can move to next step.

Put something like this to your nrpe.cfg:

command[check_hadoop_namenode]=/path/to/your/custom/script/check_hadoop_namenode.pl -optional -arguments

Then you need restart NRPE deamon service on client. Something like service nrpe restart. Just for you information, these custom script doesn't must to be binaries, you can even use simple bash script.

And finally after that, you can call the check_hadoop_namenode command from Nagios server or via local NRPE deamon:

/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_hadoop_namenode

这篇关于我如何获得一个自定义Nagios插件与NRPE一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆