-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
check_http -e breaks -f #91
Comments
Can you expand a bit? What specifically do you mean by |
I am curious also, the help states the following for -e |
Sorry, when i was to short. |
Being the fact that when you use the -e option it is just determining if the first (status) line of the server response (default: HTTP/1.) matches your list, that response is returned with all requests so the first request id what should be used. If you use the -e flag, it will not do regex matches even if you aren't redirected e.g. without -e The -e flag forces to just do a --expect match on the first (status) line of the server response |
Scott is correct - this is working as expected. Would you like to see the behavior altered in the future? |
Sorry, this is not correct. Even if the standard output doesn't show this, it does. |
This is due to the inclusion of an unmatched regex statement: -r nagios123 Remove the regex check and it works: $ ./plugins/check_http -H www.nagios.com -S -e 200 Or change the regex to a pattern that matches and it works: $ ./plugins/check_http -H www.nagios.com -S -r nagios -e 200 Some of the confusion here could be that the "pattern not found" error is not that verbose. We could at least change it to "regex pattern not found" - would that help? I do not think we want to reprint the failed regex string though as some users have fairly lengthy regex patterns they check for and it would muddy the plugin status output. |
Sorry, maybe my answer was again to short. So I wanted to show, that even when using the -e parameter a regex match is done. |
I'm going to come back around and retract my earlier consensus, I like @cp0815 proposal, I believe the plugin should be modified to perform the -f option (if specified) and then do the checking on the page. |
I agree the intended behavior should match the expected behavior. I will try to look at this tomorrow with John. |
After looking at the code and doing some testing, it seems like -e does not disable -f in the 2.1.0-beta-RC1 branch, but it does break the ability to run a regex against the redirected page: $ ./plugins/check_http -H nagios.com $ ./plugins/check_http -H nagios.com -r standard $ ./plugins/check_http -H nagios.com -r standard -f follow $ ./plugins/check_http -H nagios.com -r standard -f follow -e 301 $ ./plugins/check_http -H nagios.com -f follow -e 301 I will look at this some more. |
This can actually be a bit complicated when dealing with follow on redirects. When -e and -f follow are both specified, what should the behavior of -e be? Should it check against the first server contacted (the 301) or against the last server in the case of multiple redirects to -f follow through? |
My expectation would be the last server when -f is supplied, otherwise the first. |
I'm with @tmcnag on this. Of course it would be impossible to match a 301 or 302 with the -e, but that would be implied. |
We might want to modify -f to only follow so many redirects (configurable), both to prevent endless runs in case of circular redirects, and to all -e to have a hard endpoint so that you can match a 3XX status. |
The plugin does have a max_depth of 15, so you are correct, the -e would match the 3XX in a circular loop, or anytime 15+ redirects happen. |
Shouldn't be too difficult at all to make that configurable then. |
Correction, it will not match the -e, but will return: |
Yes, it certainly could be made a config option, but should still default to 15 |
I don't know what would be the best. It is hard to decide for all possible kinds to use the check and to know what all possbile application logics are, that could have to be monitored. Am 30. Juli 2015 22:27:50 MESZ, schrieb abrist notifications@github.com:
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet. |
I will look into this more tomorrow - I have a few different branches that get close to giving you what you want. |
My original ideas caused more issues than they solved. And while they clarified the behavior of -f when -e is supplied, they created ambiguity when just checking redirects. |
Just checking - is this improvement still in plan? I would love to have that, and I couldn't find any work-arounds |
I also would really like this improvement, was this improvement added in a newer version or is it still in the works? |
Fix for issue #91 Checking status codes and following redirects makes for compicated coding and testing. But this change seems to handle all situations properly. It is important to note, though, that anything specified by `-e` will only be compared agains the final page. So if you use `-e 301` expecting a redirect, it will error out because the status of the last page would be `200` (or some other status).
Probable fix in branch 'maint' via commit 657e3b6. Please test and report successes/failures/problems. |
Fixed in branch 'maint' via commit 657e3b6 |
@jfrickson: I found that this particular patch to 2.1.4 breaks -e logic with a 401. For instance, I run this: ./check_http -I ip.that.should.401 -S -e 401 and I got this returned: HTTP WARNING: Status line output matched "401" - HTTP/1.1 401 Unauthorized - 164 bytes in 0.935 second response time |time=0.935251s;;;0.000000 size=164B;;;0 I should have gotten an OK (I did put -e 401), but it still came back as a warning. I also tried just building check_http from the branch 'maint' (maybe something there fixed it), but that failed with the same issue. |
As heaje stated, even if the expected (-e) output line/string is found, the check returns WARNING or CRITICAL instead of OK. |
I have the same problem, I have an HTTPS check that uses |
It took me some time a an longer look to the source code to find out, that using the -e option breaks the -f option.
I checked this in the source code of the plugins we are currently using (1.4.15) and also on the newest version 2.0.3
In 2.0.3 the relevant code starts in line 1073:
if ( server_expect_yn ) {
...
} else {
...
only the else block contains the handling for the redirects.
It would by very nice if this would be fixed in future versions
The text was updated successfully, but these errors were encountered: