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