微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我正在使用以下服务来监控来自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的值.

原文地址:https://www.jb51.cc/postgresql/192488.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐