Monitoring Services with $ in the Name Using Icinga/Nagios

icingamonitoringservice

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?

Best Answer

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

Related Topic