3

Monit gives me a syntax error when the username contains an @, which would be quite common. For example, user@gmail.com below:

check host somesite with address monitoring.somesite.com
    if failed url https://user@gmail.com:password@monitoring.somesite.com/
    [...]

Doesn't seem to be anything mentioned in the documenation.

What is the correct method to include special characters in the username?

Eddie C.
  • 487
  • 1
  • 3
  • 12
jacksonp
  • 141
  • 1
  • 3
  • 9

1 Answers1

4

Monit cannot parse %40 to @ But it supports HTTP headers

For example the URL:

https://user@mail.com:password@monit.test.basic

should be converted to

Authorization: Basic dXNlckBtYWlsLmNvbTpwYXNzd29yZA==

For example:

check host BasicAuth with address monit.test.basic
    if failed
        port 443
        with protocol https method GET
        with http headers [Authorization: Basic dXNlckBtYWlsLmNvbTpwYXNzd29yZA==]
    then alert
    else if succeeded then alert

Document: https://mmonit.com/monit/documentation/monit.html#HTTP

Eddie C.
  • 487
  • 1
  • 3
  • 12
Hieu Huynh
  • 141
  • 5
  • You can use this website for generating the Basic Auth header. When I used it, it was using Javascript for calculating the string and did not send anything to internet. https://www.blitter.se/utils/basic-authentication-header-generator/ – Roland Pihlakas Oct 08 '20 at 19:10
  • You could also simply go to the network tab in your browser dev tools and take this header from the request headers. Thanks for this answer BTW – Shautieh Jul 08 '21 at 12:06