Page 1 of 1

Checking multiple services with spaces

Posted: Tue Feb 10, 2015 10:14 am
by DennisPR
Hi,

I'm having trouble checking 2 services with spaces in the names.
FYI : The service name and Display name for the services both have spaces in them.
Here is the check_command :

Code: Select all

$USER1$/check_nt -H $HOSTADDRESS$ -s "$ARG1$" -p 12489 -v $ARG2$ $ARG3$ $ARG4$
Here are the arguments I'm using
  • $ARG1$ = MyPassword
    $ARG2$ = SERVICESTATE
    $ARG3$ = -l "1st Service with spaces","2nd Service with spaces" -d SHOWALL
If I use these arguments it only checks the 1st service
If i swap both services like the $ARG3$ = -l "2nd Service with spaces","1st Service with spaces" -d SHOWALL
Nagios only checks for '2nd service with spaces"

The only solution I have found so far to split it up in 2 tests... Can anyone help me out pls ?

Re: Checking multiple services with spaces

Posted: Tue Feb 10, 2015 10:55 am
by lmiltchev
Do you see the problem in the web UI or your check also fails, when you test it from the CLI? I tested this with 3 services that have spaces in their names and it seemed to work fine for me:

Code: Select all

/usr/local/nagios/libexec/check_nt -H x.x.x.x -s "password" -p 12489 -v SERVICESTATE -l "AMD External Events Utility","NCPA Listener ncpalistener","NCPA Passive ncpapassive" -d SHOWALL
AMD External Events Utility: Started, NCPA Listener ncpalistener: Started, NCPA Passive ncpapassive: Started
Can you show us the actual command that you are running from the CLI along with the output of it?

Re: Checking multiple services with spaces

Posted: Wed Feb 11, 2015 9:46 pm
by Box293
Try this:

Code: Select all

$ARG3$ = -l '1st Service with spaces','2nd Service with spaces' -d SHOWALL
Using Single quotes for the name of the services with spaces.

If that doesn't work, also keep using single quotes BUT in the command escape the double quotes:

Code: Select all

$USER1$/check_nt -H $HOSTADDRESS$ -s \"$ARG1$\" -p 12489 -v $ARG2$ $ARG3$ $ARG4$

Re: Checking multiple services with spaces

Posted: Mon Feb 16, 2015 4:22 am
by DennisPR
Changing the $ARG3$ to single quotes fixed my issue thx !

Code: Select all

$ARG3$ = -l '1st Service with spaces','2nd Service with spaces' -d SHOWALL

Re: Checking multiple services with spaces

Posted: Mon Feb 16, 2015 9:51 am
by cmerchant
We'll go ahead and close the thread. Thanks.