How to escape $ and ! in password?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
relateqld
Posts: 41
Joined: Sun Nov 11, 2012 8:15 pm

How to escape $ and ! in password?

Post 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?
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: How to escape $ and ! in password?

Post 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...
relateqld
Posts: 41
Joined: Sun Nov 11, 2012 8:15 pm

Re: How to escape $ and ! in password?

Post by relateqld »

Happy new year! Any progress on this bug?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to escape $ and ! in password?

Post 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...
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
relateqld
Posts: 41
Joined: Sun Nov 11, 2012 8:15 pm

Re: How to escape $ and ! in password?

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to escape $ and ! in password?

Post 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$="!"
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked