Page 1 of 2

Password with exclamation sign (!) in command is not working

Posted: Thu Jan 30, 2014 2:43 pm
by imran_khan
Hello,

We are using password with exclamation sign (!) (Password:- xyzabc!!) in command to monitor link with authentication but it is not working, we are getting authentication failed error.
Normally this password is working fine while accessing link directly. There is no issue with username and password.

Thanks,
Imran Khan.

Re: Password with exclamation sign (!) in command is not wor

Posted: Thu Jan 30, 2014 2:49 pm
by tmcdonald
Exclamation points are used to separate command arguments, so they need to be treated somewhat differently.

http://support.nagios.com/forum/viewtop ... =16&t=8598

Basically you will want to edit /usr/local/nagios/etc/resource.cfg and make a new $USERX$ variable, and use that in your definition.

Re: Password with exclamation sign (!) in command is not wor

Posted: Thu Jan 30, 2014 3:16 pm
by imran_khan
Hello,

Thanks for the reply.

Please find my current command definition and service command details. Please suggest me on the basis of current details/setting.

check_sharepoint.pl command defination:-
command_name check_sharepoint.pl
command_line /usr/lib64/nagios/plugins/check_sharepoint.pl -H $ARG1$ -u $ARG2$ -p $ARG3$ -l $ARG4$ -s $ARG5$ -t $ARG6$

Service command:-
check_command check_sharepoint.pl!xyz![email protected]!xyzabc!!!'/SitePages/Home.aspx'!'Home'!15

Thanks,
Imran Khan.

Re: Password with exclamation sign (!) in command is not wor

Posted: Thu Jan 30, 2014 3:21 pm
by tmcdonald
Did you read the link I posted?

You will need to edit /usr/local/nagios/etc/resource.cfg and make a new $USERX$ variable holding your password, and use that in your definition:

Code: Select all

check_command [email protected]!$USER10$!'/SitePages/Home.aspx'!'Home'!15
For example.

Re: Password with exclamation sign (!) in command is not wor

Posted: Thu Jan 30, 2014 3:24 pm
by imran_khan
Hello,

Getting below error while try to access url which posted you.

You are not authorised to read this forum.

Thanks,
Imran Khan.

Re: Password with exclamation sign (!) in command is not wor

Posted: Thu Jan 30, 2014 3:26 pm
by tmcdonald
Here is the relevant post from that thread:
scottwilkerson wrote: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$="!"
However you should be able to just make the edit to resource.cfg, restart nagios and get it working.

Re: Password with exclamation sign (!) in command is not wor

Posted: Thu Jan 30, 2014 4:12 pm
by imran_khan
Hello,

Is there any other way?

Thanks,
Imran Khan.

Re: Password with exclamation sign (!) in command is not wor

Posted: Thu Jan 30, 2014 4:15 pm
by tmcdonald
imran_khan wrote:Hello,

Is there any other way?

Thanks,
Imran Khan.
The steps I provided are the only way to get an exclamation mark in a command definition.

Re: Password with exclamation sign (!) in command is not wor

Posted: Thu Jan 30, 2014 4:17 pm
by imran_khan
Hello,

There is two exclamation in password (xyzabc!!). So please let me know, how I can do this?

Thanks,
Imran Khan.

Re: Password with exclamation sign (!) in command is not wor

Posted: Thu Jan 30, 2014 4:23 pm
by tmcdonald
I have already told you.

You will need to edit /usr/local/nagios/etc/resource.cfg and enter in a new line with the following:

$USER10$=xyzabc!!

and save the file. You will obviously need to type in your password if it is not actually 'xyzabc!!'.

Then you will need to edit your command definition like so:

check_command check_sharepoint.pl!xyz![email protected]!$USER10$!'/SitePages/Home.aspx'!'Home'!15

and save that file. Then run:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios reload

and it should work.



The reason you cannot have a (!) in the command directly is because that character is used to separate out the command arguments, so when you put a (!) in as a password, nagios thinks that whatever comes after is a new command argument, which is wrong.