monit network check should allow other HTTP verbs than HEAD too

Issue #500 resolved
Anonymous created an issue

a test like

"if failed host localhost port 5602 proto http request / for 2 cycles then alert"

triggers a HTTP check with HEAD, but some applications does not implement HEAD, only GET requests and return an HTTP 400 in this case. Monit should allow to explicitly set the HTTP method to use for the request (e.g. GET)

tested with Monit 5.20

somehow related to #375 - allow POST

Comments (6)

  1. Tildeslash repo owner

    As a workaround, you can enable GET by extending the port test either by content check option or checksum check option - monit then needs to retrieve the content and uses GET automatically.

  2. Tildeslash repo owner

    Fixed Issue #500: HTTP protocol test: Monit still prefers the HEAD method unless response content or checksum test is enabled, but from this version on if the server returned error, it will try to fallback to GET, as some servers may not support HEAD method.

    New: Added the "method" option for http protocol test, to allow overriding the HTTP method used for the test. Only HEAD and GET methods are supported currently. Example: if failed port 443 protocol https method GET then alert

    → <<cset e1c01a39af2e>>

  3. Tildeslash repo owner

    cset 8584ce1f0a2a update: dropped the automatic HEAD->GET fallback which was added in cset e1c01a39af2e ... it could break some scenarios, such as if the user sets test for HEAD method that is expected to fail (because he want to make sure HEAD is not supported)

    To override the HEAD method, explicit "method GET" option is necessary.

  4. gnaditya

    Hi, I have the same issue where i need to make a GET call instead of HEAD. I have tried with the below line in monitrc file 'if failed host localhost port 8000 protocol http request "/configs" with content "configs" and timeout 30 seconds for 8 cycles then restart '

    But I get an error ' /etc/monitrc:41: syntax error '"configs"' '

    What am I doing wrong? I am using monit 5.21 version

  5. Log in to comment