Page 1 of 2

what is right format to check windows service with special?

Posted: Wed Nov 28, 2012 8:53 pm
by relateqld
use check_xi_service_nsclient command to check the status of windows service, but get problem with service name contains special character like $, (, space and so on.
For example, "sophos management service" contains 2 space in the name, had tried sophos management service and "sophos management service", both return
could not fetch information from server


So what is right format for such service name?

Re: what is right format to check windows service with speci

Posted: Thu Nov 29, 2012 8:38 am
by scottwilkerson
This looks correct. Although you may need to use single quotes

What version of NSClient are you running?

Re: what is right format to check windows service with speci

Posted: Thu Nov 29, 2012 5:27 pm
by relateqld
I am using newest version of nsclient++, 0.4.1.66.

Re: what is right format to check windows service with speci

Posted: Thu Nov 29, 2012 5:29 pm
by slansing
Hi relateqld,

Have you tried pushing the check through as scott suggested? With single quotes?

Code: Select all

'string with strange characters inside'

Re: what is right format to check windows service with speci

Posted: Thu Nov 29, 2012 5:42 pm
by relateqld
Test check command results:


COMMAND: /usr/local/nagios/libexec/check_nt -H raqsav1 -s "xxxx" -p 12489 -v SERVICESTATE -l 'Sophos Management Service' -d SHOWALL
OUTPUT: could not fetch information from server

COMMAND: /usr/local/nagios/libexec/check_nt -H raqsav1 -s "xxxx" -p 12489 -v SERVICESTATE -l \`Sophos Management Service\` -d SHOWALL
OUTPUT: could not fetch information from server

COMMAND: /usr/local/nagios/libexec/check_nt -H raqsav1 -s "xxxx" -p 12489 -v SERVICESTATE -l 'Sophos Management Service' -d SHOWALL
OUTPUT: could not fetch information from server

Re: what is right format to check windows service with speci

Posted: Thu Nov 29, 2012 5:58 pm
by relateqld
My bad, single quote did work for space, there is something wrong with nsclient in that server.

Can you also tell me how to escape from other special character like $?

see below:
COMMAND: /usr/local/nagios/libexec/check_nt -H raqsav1 -s "xxxx" -p 12489 -v SERVICESTATE -l 'MSSQL\$SOPHOS' -d SHOWALL
OUTPUT: MSSQL\$SOPHOS: Error

When the service name contains $, nagios will auto add \ in front of $, how to escape?

Re: what is right format to check windows service with speci

Posted: Thu Nov 29, 2012 6:07 pm
by scottwilkerson
lets try

Code: Select all

/usr/local/nagios/libexec/check_nt -H raqsav1 -s "xxxx" -p 12489 -v SERVICESTATE -l 'sophos management service' -d SHOWALL 
I remember hearing about a bug in the new version of nsclient++ where services and processes need to be in all lower case...

Re: what is right format to check windows service with speci

Posted: Thu Nov 29, 2012 6:12 pm
by relateqld
Hi scottwikerson:
single quote works for space, so lower case or upper case doesn't matter.

Now I am trying to find a way to esacpe $, do you know how?

Re: what is right format to check windows service with speci

Posted: Thu Nov 29, 2012 6:18 pm
by scottwilkerson

Re: what is right format to check windows service with speci

Posted: Thu Nov 29, 2012 6:23 pm
by relateqld
I tried that before, not working with nagios xi :?

check_nt!SERVICESTATE!-d SHOWALL -l MSSQL\\$$INSTANCE

COMMAND: /usr/local/nagios/libexec/check_nt -H raqsav1 -s "xxxx" -p 12489 -v SERVICESTATE -l MSSQL\\\\\$\$SOPHOS -d SHOWALL
OUTPUT: MSSQL\\$$SOPHOS: Error