Skip to content
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

[http_check] Bring back include_content option #2631

Merged
merged 1 commit into from Jul 1, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions checks.d/http_check.py
Expand Up @@ -34,6 +34,8 @@
from utils.proxy import get_proxy

DEFAULT_EXPECTED_CODE = "(1|2|3)\d\d"
CONTENT_LENGTH = 200


class WeakCiphersHTTPSConnection(urllib3.connection.VerifiedHTTPSConnection):

Expand Down Expand Up @@ -224,7 +226,7 @@ def _check(self, instance):
instance_proxy.pop('http')
instance_proxy.pop('https')
else:
for url in self.proxies['no'].replace(';',',').split(","):
for url in self.proxies['no'].replace(';', ',').split(","):
if url in parsed_uri.netloc:
instance_proxy.pop('http')
instance_proxy.pop('https')
Expand Down Expand Up @@ -288,8 +290,10 @@ def _check(self, instance):
else:
expected_code = http_response_status_code

message = "Incorrect HTTP return code for url %s. Expected %s, got %s" % (
message = "Incorrect HTTP return code for url %s. Expected %s, got %s." % (
addr, expected_code, str(r.status_code))
if include_content:
message += '\nContent: {}'.format(r.content[:CONTENT_LENGTH])

self.log.info(message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that would make sense, good call @yannmh. Adding it.


Expand All @@ -312,10 +316,13 @@ def _check(self, instance):
else:
self.log.info("%s not found in content" % content_match)
self.log.debug("Content returned:\n%s" % content)
message = 'Content "%s" not found in response.' % content_match
if include_content:
message += '\nContent: {}'.format(content[:CONTENT_LENGTH])
service_checks.append((
self.SC_STATUS,
Status.DOWN,
'Content "%s" not found in response' % content_match
message
))
else:
self.log.debug("%s is UP" % addr)
Expand Down