Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

# FROM THE COMMAND LINE THIS WORKS (note the arguments to "-a"):

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

## because NSC.INI has this:

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

# BUT the "-n" argument is optional, so I want to be able to call simple_add2 either way:

like this:

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

or like this:

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

# HERE IS MY CURRENT COMMAND AND SERVICE:

I do not want to create two different commands and two different External Scripts listings for the same command simply because I want to call it with or without the -n argument... just imagine if I wrote a script with several optional keyword arguments. The explosion of commands and External Scripts would be combinatoric.

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
}
share|improve this question
add comment

1 Answer

I only mention this since I didn't realise it for the longest time; $ARG1$ can have quite a lot of stuff in it. Have you considered:

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
}
share|improve this answer
    
so, basically adding spaces in your argument alleviates the need for optional args. interesting –  Chris Jul 8 '11 at 19:46
    
this doesn't really work in Centreon because $ARGn$ wraps values in single quotes... –  Chris Jul 8 '11 at 19:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.