Monitor Services with $ in the service name in Icinga / Nagios

Solution 1:

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

Solution 2:

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$