gpt4 book ai didi

linux - 使用 Nagios 磁盘进行监控 - NRPE - Linux

转载 作者:太空狗 更新时间:2023-10-29 12:31:21 24 4
gpt4 key购买 nike

我在 Nagios/NRPE 服务方面遇到如下问题:

我已经完成了每个文件的配置,但无法识别客户端上 NRPE 发送的 nagios 响应:

文件:/etc/nagios/nrpe.cfg(客户端)

command[check_users]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/mapper/VG_opt-LV_opt
command[check_zombie_procs]=/usr/lib64/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib64/nagios/plugins/check_procs -w 150 -c 200

文件:services.cfg(服务器)

define service{
use generic-service
host_name 192.168.160.10, 192.168.160.11, 192.168.160.12
service_description Disk Space
notification_options w,u,c,r
check_command check_nrpe!check_disk
}

很明显我重启了客户端和服务器上的服务,其他通过NRPE的协商得到了结果,因为进程数,CPU和RAM是check_disk的问题。

本地用check_disk得到的结果是:

DISK OK - free space: /opt 34024 MB (76% inode=98%);| /opt=10522MB;37544;42237;0;46930

网络结果

Disk SpaceUNKNOWN    2014-09-26 09:18:31    0d 15h 52m 53s    4/4    (No output returned from plugin) 

如果我从 nagios 服务器 得到结果,那就更奇怪了。

$ ./check_nrpe -H 192.168.160.10 -c check_disk
DISK OK - free space: /opt 33389 MB (74% inode=98%);| /opt=11156MB;37544;42237;0;46930

通过网络:

**(No output returned from plugin)**

(No output returned from plugin)
NRPE Plugin for Nagios
Copyright (c) 1999-2008 Ethan Galstad (nagios@nagios.org)
Version: 2.15
Last Modified: 09-06-2013
License: GPL v2 with exemptions (-l for more info)
SSL/TLS Available: Anonymous DH Mode, OpenSSL 0.9.6 or higher required
\nUsage: check_nrpe -H <host> [ -b <bindaddr> ] [-4] [-6] [-n] [-u] [-p <port>] [-t <timeout>] [-c <command>] [-a <arglist...>]
\nOptions:
-h = Print this short help.
-l = Print licensing information.
-n = Do no use SSL
-u = Make socket timeouts return an UNKNOWN state instead of CRITICAL
<host> = The address of the host running the NRPE daemon
<bindaddr> = bind to local address
-4 = user ipv4 only
-6 = user ipv6 only
[port] = The port on which the daemon is running (default=5666)
[timeout] = Number of seconds before connection times out (default=10)
[command] = The name of the command that the remote daemon should run
[arglist] = Optional arguments that should be passed to the command. Multiple
arguments should be separated by a space. If provided, this must be
the last option supplied on the command line.
\nNote:
This plugin requires that you have the NRPE daemon running on the remote host.
You must also have configured the daemon to associate a specific plugin command
with the [command] option you are specifying here. Upon receipt of the
[command] argument, the NRPE daemon will run the appropriate plugin command and
send the plugin output and return code back to *this* plugin. This allows you
to execute plugins on remote hosts and 'fake' the results to make Nagios think
the plugin is being run locally.
\n

最佳答案

这可能早就应该了,但我必须做出回应。

@AlainCollins 评论道:

..how is the check_nrpe command defined?

define command{
command_name check_nrpe
command_line /usr/lib64/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$
}

以上是基本的 check_nrpe 命令。您在这里遇到的问题是您正在尝试从 nrpe.cfg 运行不需要参数的定义命令。当您定义命令时,上面 NRPE 命令定义中的 $ARG2$ 是“-a”获取其值的位置。因此,如果您提供第一个参数“-c”作为命令 check_disk,它不会获得 $ARG2$ 的值。

要解决这个问题,您有 2 个选择:

1) 在 Disk Space check_command 定义的 command 参数后添加一个占位符“!”:

define service{
use generic-service
host_name 192.168.160.10, 192.168.160.11, 192.168.160.12
service_description Disk Space
notification_options w,u,c,r
check_command check_nrpe!check_disk!
}

2) 使用 /etc/nagios-plugins/config/check_nrpe.cfg 中提供的“check_nrpe_1arg”命令 - 这个命令是为不需要参数的插件设计的,可以像常规 check_nrpe:

define command{ 
command_name check_nrpe_1arg
command_line /usr/lib64/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

关于linux - 使用 Nagios 磁盘进行监控 - NRPE - Linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26102929/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com