Page 1 of 1

check_nt can not find service with $ in name - MSSQL$MSFW

Posted: Fri Aug 28, 2015 9:18 am
by itheodoridis
Hello all.
I am using Nagios for a few years now and my production machine runs on ubuntu 14.04.3 LTS Server with Nagios 3.5 and Nagios Plugins 2.0.3.
I am working towards moving my production to 4.1.1 with plugins 2.1.1 but I have run into a problem.
I can not correctly check if an MSSQL service for ISA Server 2006 is started with my test installation on Nagios 4.1.1 and plugins 2.1.1

The command used is check_nt in order to check if a service is started. For example in the config you would find:
define service{
use generic-service;
hostgroup_name ProxyServers;
service_description MSSQL Service;
check_command check_nt!SERVICESTATE!-d SHOWALL -l 'MSSQL\$MSFW'
contact_groups proxyservers_admins,admins
notification_period 24x7no45amrestart
}

while the check_nt command is defined as follows:
# 'check_nt' command definition
define command{
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$
}

(I will not put in the part where the group and hosts for ProxyServers is configured for obvious reasons).

So what happens is that my 3.5/2.0.3 system checks for the MSSQL$MSFW service and responds it is started.
However the 4.1.1/2.1.1 system reports:
Failed to open service MSSQL$MSFW$: 123: The filename, directory name, or volume label syntax is incorrect.

I have also tried with various ways like this:
check_command check_nt!SERVICESTATE!-d SHOWALL -l "MSSQL\\$MSFW"
On the 3.5 system, this workds fine. On the 4.1.1 I get:
Failed to open service MSSQL: 123: The filename, directory name, or volume label syntax is incorrect.
I tried working out the problem as I had done in the past so I tried through the command line this is how it went (I replaced the actual hostname and delete the part where the hostname and path shows in the command line, all checks executed in the libexec dir and on the 4.1.1 machine):
./check_nt -H hostname -p 12489 -v SERVICESTATE -d SHOWALL -l "MSSQL\$MSFW"
MSSQL$MSFW: Started
./check_nt -H hostname -p 12489 -v SERVICESTATE -d SHOWALL -l 'MSSQL$MSFW'
MSSQL$MSFW: Started
./check_nt -H hostname -p 12489 -v SERVICESTATE -d SHOWALL -l MSSQL$MSFW
Failed to open service MSSQL: 1060: The specified service does not exist as an installed service.

./check_nt -H hostname -p 12489 -v SERVICESTATE -d SHOWALL -l MSSQL\$MSFW
MSSQL$MSFW: Started

./check_nt -H hostname -p 12489 -v SERVICESTATE -d SHOWALL -l "MSSQL\\$$MSFW"
Failed to open service MSSQL\1101MSFW: 123: The filename, directory name, or volume label syntax is incorrect.

I know I must be missing something but I have no idea what that is.
If anyone has a clue, I would be grateful.
Thank you and all the best to your admin efforts.
Ioannis Theodoridis

Re: check_nt can not find service with $ in name - MSSQL$MSF

Posted: Fri Aug 28, 2015 10:10 am
by hsmith
Can you try putting $ARG2$ in single quotes in the command definition?

Code: Select all

# 'check_nt' command definition
define command{
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ '$ARG2$'
}

Re: check_nt can not find service with $ in name - MSSQL$MSF

Posted: Fri Aug 28, 2015 10:31 am
by itheodoridis
sure. How about the other cfg part though? (the service check field)
i tried with 'MSSQL$MSFW' (single quotes and actual service name). I will let you know how it goes.
Thank you for the reply.

Re: check_nt can not find service with $ in name - MSSQL$MSF

Posted: Fri Aug 28, 2015 10:55 am
by hsmith
itheodoridis wrote:sure. How about the other cfg part though? (the service check field)
i tried with 'MSSQL$MSFW' (single quotes and actual service name). I will let you know how it goes.
Thank you for the reply.
I would just leave service the same for now, if that doesn't work, try to single quote it as well. Let me know what you come up with. I don't have any MSSQL test servers spun up here to test against at the moment, otherwise I'd try to replicate this one for you.

Re: check_nt can not find service with $ in name - MSSQL$MSF

Posted: Sun Aug 30, 2015 7:16 pm
by Box293
I believe you need a backslash and two dollar signs:

Code: Select all

MSSQL\$$MSFW

Re: check_nt can not find service with $ in name - MSSQL$MSF

Posted: Mon Aug 31, 2015 3:23 am
by itheodoridis
I am afraid that changing the check_nt command broke every other service check I am doing for other systems.. I will try to work it out but let see if I got this clear :
I will keep the single quotes in the definition for check_nt and leave them out in the service check?
or do I remove them from both definitions and use the backslash and double dollar sign?
I would love to come to the conference but I am having trouble already for convincing the management to let some engineers go to cisco live conferences (we are mainly network engineers) so getting a chance for nagios conference is probably out of the question..
I never give up hope though, I always keep trying.
Thanks again,
Ioannis Theodoridis

Re: check_nt can not find service with $ in name - MSSQL$MSF

Posted: Mon Aug 31, 2015 7:05 am
by itheodoridis
Well I am happy to report that your suggestion seems to have fixed things!
So here is what I did:
- for the command definition of check_nt I changed things back to default like it was before (no quotes):
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$
- for the service check definition I used only the backslash and double dollar, no quotes like you said:
check_command check_nt!SERVICESTATE!-d SHOWALL -l MSSQL\$$MSFW
It worked like a charm!! I can finally upgrade my production system to 4.1.1 now! I am very gratefull for your help and support.
I also hope more people may find this helpful.
Thanks again,
Ioannis Theodoridis.

Re: check_nt can not find service with $ in name - MSSQL$MSF

Posted: Mon Aug 31, 2015 9:14 am
by tmcdonald
I'll be closing this thread now, but feel free to open another if you need anything in the future!