Page 1 of 1

How to escape $ and ! in password?

Posted: Tue Dec 11, 2012 12:14 am
by relateqld
I got similar post about $ in the service name and $"$" works fine, this time is password.

If password contain $ or !,

COMMAND: /usr/local/nagios/libexec/check_mssql_server.py -H raqsql2 -U 'sa' -P '\$QLxxxx!' -p 1433 --averagewait --warning 20 --critical 30
OUTPUT: CRITICAL:Unable to access SQL Server.

(see the system auto add \ in front of $, that is reason it can't connect with SQL server"

Run same command directly from nagios server ssh:
[root@nagiosxi libexec]# ./check_mssql_server.py -H raqsql2 -U 'sa' -P '$QLxxxx!' -p 1433 --averagewait --warning 20 --critical 30
CRITICAL:Average Wait Time is 2296.0ms|Average_Wait_Time=2296.0ms;;;;

So the question is: how to escape $ or ! in password?

Re: How to escape $ and ! in password?

Posted: Tue Dec 11, 2012 11:28 am
by mguthrie
This should get you past the $ sign. See if that works.

http://support.nagios.com/wiki/index.ph ... ck_Command

There is a known issue with form repopulation when there is an ! in the password, and that is currently on our bug list. One workaround you could do in the meantime is add a new $USERx$ macro to the /usr/local/nagios/etc/resource.cfg file and then just use that in the service definition. That only works well though if there's a common password for multiple machines...

Re: How to escape $ and ! in password?

Posted: Wed Jan 02, 2013 7:27 pm
by relateqld
Happy new year! Any progress on this bug?

Re: How to escape $ and ! in password?

Posted: Thu Jan 03, 2013 10:26 am
by scottwilkerson
relateqld wrote:Happy new year! Any progress on this bug?
Did you read mguthrie's reply?
mguthrie wrote:This should get you past the $ sign. See if that works.

http://support.nagios.com/wiki/index.ph ... ck_Command

There is a known issue with form repopulation when there is an ! in the password, and that is currently on our bug list. One workaround you could do in the meantime is add a new $USERx$ macro to the /usr/local/nagios/etc/resource.cfg file and then just use that in the service definition. That only works well though if there's a common password for multiple machines...

Re: How to escape $ and ! in password?

Posted: Thu Jan 03, 2013 6:57 pm
by relateqld
solution in the link doesn't work.

macro solution doesn't work for test command, but works for service check, :o Anyway, that is what I want, thanks

Re: How to escape $ and ! in password?

Posted: Fri Jan 04, 2013 9:46 am
by scottwilkerson
It does kind of depend on the quoting that may or may not be around the field you are using.

In your example instead of this

Code: Select all

/usr/local/nagios/libexec/check_mssql_server.py -H raqsql2 -U 'sa' -P '\$QLxxxx!' -p 1433 --averagewait --warning 20 --critical 30
you would need to go with this (removing the single quote)

Code: Select all

/usr/local/nagios/libexec/check_mssql_server.py -H raqsql2 -U 'sa' -P \\$$QLxxxx$USER9$ -p 1433 --averagewait --warning 20 --critical 30
where you have added the following to the resources.cfg and restarted nagios

Code: Select all

$USER9$="!"