stringnagios

How to pass password value string contains ! in nagios command for monitoring purpose


In nagios cfg if I want to pass multi parameters to command, the value is seperated by !

My problem is that the password I'm trying to pass to nagios cfg file contains !, which causing problem for nagios to think it's a separator. Is there any other way to change seperator or literally change the meaning of ! in password string? e.g.

define service{
 use generic-service
 host_name 10.62.85.10
 service_description ESXi Hardware Check
 check_command check_esxi_hardware!root!Password123!!auto
}

nagios thinks the $ARG1$ is root $ARG2$ is Password123 and $ARG3$ is null

actually the value I want to pass is $ARG1$ is root $ARG2$ is Password123! and $ARG3$ is auto


Solution

  • First, you should use Nagios user macros for store sensitive information like password. Just look to your Nagios private/resource.cfg file for more information.

    Nagios uses ! to separate input arguments in the configuration.
    Everything is great until you need to use a ! or $ within one of your variables. At this point you need to escape the special character.

    You should use a backslash "\" to do this for the ! and $ characters in your Nagios configuration files, like: \! or \$.