How can I use '!' in the values supplied in my check


I have an issue where I need to supply a string as a parameter to a check command. The issue is that sometimes this string has an exclamation point. Of course this confuses how nagios is parsing the check_command parameters since nagios itself uses ! marks as field delimeters.

I have tried enclosing my string in single quotes but the ! mark continues
to confuse nagios.

Anyone have any suggestions on how to get around this?


Try using a backslash \ previous to the ! like this:


I try that double backslash but it doesn’t work for me. I need to use a ftp password with the command. I put this on services.cfg:

check_command check_ftpdir!username!gt.ko\\!6!/

And, for test, I put this in checkcommands.cfg

define command{
    command_name check_ftpdir
    command_line echo -en "$HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$\n" 

As you can see the pass is something like “gt.ko!6” and the desired directory to check is “/”. The output is somthing like the following.I try with one, two and none backslash:

Two backslashes: “ username gt.ko\ 6” (pass=gt.ko, directory=6)
One backslash: “ username gt.ko\ 6” (pass=gt.ko, directory=6)
None: “ username gt.ko 6” (pass=gt.ko, directory=6)

Please, some help!!


Try putting the exclamation point in your command_line definition instead and remove it from the check_command definition.

If this doesn’t work another option is to remove the parameter passing from the service definition on your nagios server and move it to the command definition (e.g. if you are using nrpe) on the system you are monitoring.


I can’t touch anything in the monitored system. And change the check_command.cfg in the way you mention is nasty thing and…in order to make it work I can (actually, I have done this) also change the script asociated code, wich is still a very nasty thing. The point is that I need to use that check_command (check_ftpdir) with a number of machines.

Sooo I need to make that exclamation mark work. Any more ideas??

Forgive my english. I hope I explain myself.


You don’t have a lot of options here.

If you have other services which currently use command_name check_ftpdir, create a new one, e.g. check_ftpdir_special which has the same exact command definition as check_ftpdir, but it includes the exclamation point in it. That way you won’t effect the other services that also use the check_ftpdir command.

Of course you will have to define the new service with the check_command of check_ftpdir_special to use the new command.