如果Nagios脚本使用关键字而不是位置参数,那么您将如何设置Nagios?

#从命令行这个作品(注意“-a”的参数):

./check_nrpe -p 12490 -H 10.246.107.167 -t 120 -c simple_add2 -a 4 56 

##因为NSC.INI有这样的:

 simple_add2=perl scripts\simple_add2.plx -m $ARG1$ -n $ARG2$ 

#但是“-n”参数是可选的,所以我希望能够以任何方式调用simple_add2:

喜欢这个:

 ./check_nrpe -p 12490 -H 10.246.107.167 -t 120 -c simple_add2 -a -m 4 -n 56 

或者像这样:

  ./check_nrpe -p 12490 -H 10.246.107.167 -t 120 -c simple_add2 -a -m 4 

#这里是我目前的命令和服务:

我不想为同一个命令创build两个不同的命令和两个不同的外部脚本列表,只是因为我想用-n参数或不使用-n参数来调用它…试想如果我用几个可选的关键字参数编写脚本。 命令和外部脚本的爆炸将是组合的。

 define command { command_name add_numbers_service command_line $USER1$/check_nrpe -p 12490 -H $HOSTADDRESS$ -u -t 90 -c \ simple_add_pln -a $ARG1$ $ARG2$ } define service { host_name awswinserver service_description simple-addition-test check_command add_numbers_service!4!5 use generic-service } 

我只是提到这一点,因为我没有意识到这个时间最长的时间。 $ ARG1 $可以有很多东西在里面。 你有没有考虑过:

 simple_add2=perl scripts\simple_add2.plx -m $ARG1$ define command { command_name add_numbers_service command_line $USER1$/check_nrpe -p 12490 -H $HOSTADDRESS$ -u -t 90 -c \ simple_add_pln -a $ARG1$ } define service { host_name awswinserver service_description simple-addition-test-1 check_command add_numbers_service!4 use generic-service } define service { host_name awswinserver service_description simple-addition-test-2 check_command add_numbers_service!4 -n 56 use generic-service }