加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

debian – Nagios命令不传输所有参数

发布时间:2020-12-13 16:24:43 所属栏目:百科 来源:网络整理
导读:我正在使用以下服务来监控来自nagios的postgres数据库: define service{ use test-service ; Name of servi$ host_name DEMOCGN002 service_description Postgres State check_command check_nrpe!check_pgsql!192.168.1.135!test!test!test notifications_
我正在使用以下服务来监控来自nagios的postgres数据库:
define service{
       use                             test-service         ; Name of servi$
       host_name                       DEMOCGN002
       service_description             Postgres State
       check_command                   check_nrpe!check_pgsql!192.168.1.135!test!test!test
       notifications_enabled           1
       }

在远程计算机上我配置了命令:

command[check_pgsql]=/usr/lib/nagios/plugins/check_pgsql -H $ARG1$-d $ARG2$-l $ARG3$-p $ARG4$

在syslog中,我可以看到该命令已执行,但只传输了一个参数:

Oct 20 13:18:43 DEMOSRV01 nrpe[1033]: Running command: /usr/lib/nagios/plugins/check_pgsql -H 192.168.1.134 -d  -l  -p 
Oct 20 13:18:43 DEMOSRV01 nrpe[1033]: Command completed with return code 3 and output: check_pgsql: Database name is not valid - -l#012Usage:#012check_pgsql [-H <host>] [-P <port>] [-c <critical time>] [-w <warning time>]#012 [-t <timeout>] [-d <database>] [-l <logname>] [-p <password>]
Oct 20 13:18:43 DEMOSRV01 nrpe[1033]: Return Code: 3,Output: check_pgsql: Database name is not valid - -l#012Usage:#012check_pgsql [-H <host>] [-P <port>] [-c <critical time>] [-w <warning time>]#012 [-t <timeout>] [-d <database>] [-l <logname>] [-p <password>]

为什么参数2,3和4缺失?

您将监视主机上定义的参数与远程主机上的参数混合在一起. $ARGx $宏不能在NRPE主机上使用.

默认情况下,check_nrpe命令定义如下:

define command{
    command_name    check_nrpe
    command_line    $USER1$/check_nrpe -H $HOSTADDRESS$-c $ARG1$-t 120
}

在远程主机上,您必须使用“真实”值,如下所示:

command[check_pgsql]=/usr/lib/nagios/plugins/check_pgsql -d test -l test -p test

并且可以从Nagios主机调用此命令:

define service{
    use                     test-service         
    host_name               DEMOCGN002
    service_description     Postgres State
    check_command           check_nrpe!check_pgsql
    notifications_enabled   1
    }

无需传递IP地址,因为它获取host_name的值.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读