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?

DKNUCKLES
  • 4,028
  • 9
  • 45
  • 60

4 Answers4

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 ;)

krissi
  • 3,317
  • 1
  • 18
  • 22
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$
BMDan
  • 7,129
  • 2
  • 22
  • 34
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
ThatGraemeGuy
  • 15,314
  • 12
  • 51
  • 78
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

trpt4him
  • 243
  • 1
  • 7