Page 1 of 1

service with space and $ in name

Posted: Thu Jul 24, 2014 6:36 am
by MichielvM
We want to monitor a service running on a windows machine.
Normally this is not a problem, except that this one has both a space and a $ sign in the name.

We tried the following $ARG$ formats;

Code: Select all

-l "Ipswitch WS_FTP Web Server"$$"FTPServer" -d SHOWALL
-l "Ipswitch WS_FTP Web Server$$FTPServer" -d SHOWALL
-l Ipswitch' 'WS_FTP Web Server"$$"FTPServer -d SHOWALL
None of which worked.

The current $ARG3$ line is:
-l "Ipswitch WS_FTP Web Server\$FTPServer" -d SHOWALL
When running this from the commanline, It's fine

Code: Select all

/usr/local/nagios/libexec/check_nt -H <ip> -s "" -p 12489 -v SERVICESTATE -l "Ipswitch WS_FTP Web Server\$FTPServer" -d SHOWALL
 Ipswitch WS_FTP Web Server$FTPServer: Started
But when Xi does it's magic, it reports as critical and "not found"
It seems like Xi does not correctly converts or that the "Test Check Command" is buggy and ironically gives the correct output.

Re: service with space and $ in name

Posted: Thu Jul 24, 2014 9:38 am
by lmiltchev
It seems like Xi does not correctly converts or that the "Test Check Command" is buggy and ironically gives the correct output.
Testing from within the CCM works most of the time, but not 100%. It is placed there for convenience and it's not meant to be a substitute for testing from the CLI. I would recommend testing from the command line then scheduling an immediate check from the "Service Status Detail" page. Other words, testing from the CCM may fail but the check itself might work just fine.

Re: service with space and $ in name

Posted: Thu Jul 24, 2014 10:29 pm
by Box293
I'm assuming you're using the command check_xi_service_nsclient.

Copy this command and call it check_xi_service_nsclient_alt
Specify the command as follows:

Code: Select all

$USER1$/check_nt -H $HOSTADDRESS$ -s "$ARG1$" -p 12489 -v $ARG2$ -l \"$ARG3$\" -d SHOWALL $ARG4$
Apply config

Edit the service you are having issues with.
Change the command to check_xi_service_nsclient_alt

Change $ARG3$ to:

Code: Select all

Ipswitch WS_FTP Web Server\$FTPServer
or

Code: Select all

Ipswitch WS_FTP Web Server$$FTPServer
Basically by escaping the quotes around $ARG3$ in the command line, when the command runs it should properly send the whole field as one argument.

I just can't remember if you escape the $ sign with a backslash or an extra $.

Re: service with space and $ in name

Posted: Fri Jul 25, 2014 10:36 am
by MichielvM
@Box293, Thanks for the help.
I have tried your suggestions, none of them work.

I did manage to copy the generated code and paste that to the cli and got "started" as result.
However the same check shows in Xi as error or not found.

Happily tweaking along, I made some changes here and there, only to get this

Code: Select all

/usr/local/nagios/libexec/check_nt -H 10.74.46.134 -s "" -p 12489 -v SERVICESTATE -l "Ipswitch WS_FTP Web Server\\\$FTPServer" -d SHOWALL
Where did these \\\ come from? Needless to say that didn't cut it either.

Alas, the weekend is upon us. I'm through for now.
Any suggestions? I will try them monday morning.

Re: service with space and $ in name

Posted: Fri Jul 25, 2014 12:33 pm
by sreinhardt
Can you paste the command that worked from the CLI? My honest guess is that this is entirely failing due to the test command buttons extra filtering thanks to php. NSclient does need some escaping, but whatever worked properly from the cli should absolutely work from nagios as well, just not likely the test command button.

Re: service with space and $ in name

Posted: Fri Jul 25, 2014 12:55 pm
by lmiltchev
Go to Home->Service Detail->$FTPServer->Configure->Re-configure this services, modify the command to look something like this:

Code: Select all

check_xi_service_nsclient!password!SERVICESTATE!-l \$$FTPServer -d SHOWALL
and click on "Update". Let me know if this helped.

Re: service with space and $ in name

Posted: Sun Jul 27, 2014 9:14 pm
by Box293
I setup a service on a Windows machine identical to yours to test it.

Here is the service definition in CCM:
Selection_078.png
NOTE: $ARG3$ is:

Code: Select all

-l 'Ipswitch WS_FTP Web Server$$FTPSERVER' -d SHOWALL
Here is the service state once it was checked:
Selection_079.png
In these circumstances the "Test Check Command" button does not work due to the special characters. Here you can see it is not working:
Selection_080.png

Re: service with space and $ in name

Posted: Tue Jul 29, 2014 3:59 am
by MichielvM
Well, that did the trick!
I've tried so many combinations with single quotes and dollars and backslashes, that I honestly can't say if I tried this one, but hey! It works!
Thanks!! :D