1

I'm trying to set up monitoring on a couple of MSSQL instances that exist on my Windows servers. The issue here is that if the service name contains a $ (for example, MSSQL$PROD)then the check_nt command will return a warning of null.

The following is an example of what I have in windows.cfg

define service{
        use                     generic-service
        host_name               SERVERNAME
        service_description     MSSQL Service
        check_command           check_nt!SERVICESTATE!-d SHOWALL -l MSSQL$PROD
        }

I have tried surrounding the service name with " " (which works with services with spaces) and putting a backslash before the $ in the service name with no luck. Does anyone know if this can be done?

3

You have to escape the $ with another $ and single-quote the name:

define service{
        use                     generic-service
        host_name               SERVERNAME
        service_description     MSSQL Service
        check_command           check_nt!SERVICESTATE!-d SHOWALL -l 'MSSQL$$PROD'
        }

alternatively you can omit the single quotes by using MSSQL\$$PROD. I like the first call more ;)

1

Krissi has the right answer.

I just want to mention an option which might be easier to parse: change your command definition to take another $ARG$, whereupon the complexity of this sort of escaping is handled in your command definition instead of in each service. So now your service looks like:

check_command    check_nt!SERVICESTATE!-d SHOWALL -l MSSQL!PROD

and in your commands.cfg:

command_line     /path/to/commmand --someopt value1 $ARG1$"$$"$ARG2$
0

You need to "quote" it and double up the $ sign for some reason.

For example the service name for Windows Internal Database is "MSSQL$MICROSOFT##SSEE".

My check_command:

check_command           check_nt_srv!MSSQL"$$"MICROSOFT\#\#SSEE
0

I tried the answers above to no avail, and am also trying to monitor SQL Server instances. Now, in 2017, it appears that NOT doubling up the $ works, as long as you maintain the quotes:

check_nt -H xx.xx.xx.xx -s "" -p 12489 -v SERVICESTATE -l 'MSSQL$BLAHBLAH' -d SHOWALL

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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