Nagios: Escape dollar character

Some services (such as MSSQL instances) include a dollar character ($) in their name. A few weeks ago, I had to add a service called “$02_JBoss Server” to our internal Nagios configuration. After searching through the Nagios documentation and FAQs, this is what I found:

For Nagios 3, add two backslashes and a second dollar (\$) symbol, like this: check_command check_command check_nt!SERVICESTATE!-d SHOWALL -l MSSQL\$$INSTANCE

The above example actually has a small error in it, because there is no second backslash (even though it says so in the description)!

The correct way to check a service named “$02_JBoss Server” is to use a definition like this:

check_command           check_nrpe_args!CheckServiceState!ShowAll "\\$$02_JBoss Server"