Page 1 of 2

check_http unable to use pass with "!"

Posted: Mon Jun 04, 2018 8:57 am
by nagiosEngie
Hello Nagios Crew,

I am having an issue wuth the check_http command.
My check uses authentication with special characters ex. user:password!

The password has a "!" in it, and being this the separator character for nagios commands output it will interpret it giving me the 401 unauthorized message.
How can I escape this character in passwords:

I have tied (taking hints from the forum) the following:

-a "user:password\!"
-a "user\password"!""
-a user:password$!
-a user:password$$!
-a user:$USER9$ (assigned the pass to a macro component)
-a user:password\\!
-a "user:password\\!"

None of these worked.
Any outher sugestions?

Thanks
Sandro

Re: check_http unable to use pass with "!"

Posted: Mon Jun 04, 2018 10:28 am
by scottwilkerson
The exclamation point is special and this article goes over how to overcome the issue
https://support.nagios.com/kb/article.php?id=580

Re: check_http unable to use pass with "!"

Posted: Tue Jun 05, 2018 3:56 am
by nagiosEngie
Hello Scott,
I have already tried the solutionso proposed in the article. I think the parsing in the http_check command dose not follow the example.
I tried through command line and webgui as you can see in the printscreens with no luck.

The credentials are <domain>\<user>:<passwith!>

Using backslash to escape the "!" did not work.

Any other sugestions?

Thanks
Sandro

Re: check_http unable to use pass with "!"

Posted: Tue Jun 05, 2018 8:50 am
by scottwilkerson
Did you look at the Solutions section at the bottom of that doc?

Re: check_http unable to use pass with "!"

Posted: Tue Jun 05, 2018 10:36 am
by nagiosEngie
Hi,
the WMI document dose not have any info about special characters. The only solution is the authentication file with user and pass written in it but for what I can see there is no option for this in check_http

As I said in my forst mail I already tried the user macro method with no success. As in image.

I am unable to manage a pass with "!" in it but cannot ask the customer to change all his passwords.
Any other solution?

Thanks
Sandro

Re: check_http unable to use pass with "!"

Posted: Tue Jun 05, 2018 12:50 pm
by scottwilkerson
scottwilkerson wrote:The exclamation point is special and this article goes over how to overcome the issue
https://support.nagios.com/kb/article.php?id=580
This document
solutions.PNG

Re: check_http unable to use pass with "!"

Posted: Wed Jun 06, 2018 7:05 am
by nagiosEngie
Hello,
I already tried (as I said in the 2 previuos posts that I have tried the user macro method.
I have modified the resaource.cfg file ad defined the password as in image.
I have tried defining the pass in the following ways:

$USER9$=password!
$USER9$="password!"
$USER9$=!
$USER9$="!"

Then using the $USER9$ variable in the command but with no success.

So please can you give a working solution?

Thanks
Sandro

Re: check_http unable to use pass with "!"

Posted: Wed Jun 06, 2018 8:38 am
by mcapra
The bang (!) is a reserved character in most shells as well as a reserved character in Nagios Core itself, so your escaping considerations are two-fold: first for Nagios Core, then for the shell.

Try this combination of macros and escaping:

Code: Select all

$USER9$=someuser:somepassword!

...

-a '$USER9$'
With special attention to the single-quotes around $USER9$. That worked for me.

This should also work:

Code: Select all

$USER9$=someuser:somepassword\!

...

-a $USER9$
Where we are again escaping ! exclusively for the benefit of the shell.

Admittedly it's not spelled out in simple language, all the tools required to solve this problem were in the aforementioned KB article. Though perhaps the article should be updated to discuss some of the basics around reserved shell characters as well as Nagios Core characters. This is definitely not the first time that article has been referenced and the solution was in escaping the shell characters.

Re: check_http unable to use pass with "!"

Posted: Wed Jun 06, 2018 9:20 am
by nagiosEngie
Hello,
thank you all for your replies, I think I found out why this is not working.
The site I am trying to access supports NTLM authentication only, and from what I know this is not supported in check_http script.
Your suggestions will be anyway usefull for the future.
Do you have a work around for the NTLM problem?

Thanks
Sandro

Re: check_http unable to use pass with "!"

Posted: Wed Jun 06, 2018 9:21 am
by mcapra
Check out this post from the greatness himself @ssax:
https://support.nagios.com/forum/viewto ... 07#p229207

All the escaping considerations likely still apply.

EDIT: The final version of that plugin is actually further down the thread:
https://support.nagios.com/forum/viewto ... 07#p229385