diff --git a/traefik/.flake8 b/traefik/.flake8 deleted file mode 100644 index f8911b3276..0000000000 --- a/traefik/.flake8 +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -ignore = W292,E226,E501,F401,E303 \ No newline at end of file diff --git a/traefik/README.md b/traefik/README.md index c9524b3c63..53650608ff 100644 --- a/traefik/README.md +++ b/traefik/README.md @@ -24,7 +24,7 @@ init_config: instances: - host: 10.1.2.3 port: "8080" - path: health + path: "/health" ``` Configuration Options: diff --git a/traefik/conf.yaml.example b/traefik/conf.yaml.example index d2199ee283..31434176cf 100644 --- a/traefik/conf.yaml.example +++ b/traefik/conf.yaml.example @@ -3,4 +3,4 @@ init_config: instances: - host: 10.1.2.3 port: "8080" - path: health \ No newline at end of file + path: "/health" \ No newline at end of file diff --git a/traefik/datadog_checks/traefik/traefik.py b/traefik/datadog_checks/traefik/traefik.py index 6eb27030db..507c73f7a5 100644 --- a/traefik/datadog_checks/traefik/traefik.py +++ b/traefik/datadog_checks/traefik/traefik.py @@ -3,7 +3,6 @@ # Licensed under a 3-clause BSD style license (see LICENSE) import requests -import json from datadog_checks.checks import AgentCheck from datadog_checks.errors import CheckException @@ -21,14 +20,14 @@ def check(self, instance): raise CheckException("Configuration error, please fix traefik.yaml") try: - url = "http://" + host + ":" + port + path + url = 'http://{}:{}{}'.format(host, port, path) response = requests.get(url) response_status_code = response.status_code if response_status_code == 200: - self.service_check('traefik.health', self.OK, tags=None, message="") + self.service_check('traefik.health', self.OK) - payload = json.loads(response.text) + payload = response.json() if 'total_status_code_count' in payload: values = payload['total_status_code_count'] @@ -45,10 +44,10 @@ def check(self, instance): self.log.warn('Field total_count not found in response.') else: - self.service_check('traefik.health', self.CRITICAL, tags=None, message="Traefik health check return code is not 200") + self.service_check('traefik.health', self.CRITICAL, message="Traefik health check return code is not 200") except requests.exceptions.ConnectionError: - self.service_check('traefik.health', self.CRITICAL, tags=None, message="Traefik endpoint unreachable") + self.service_check('traefik.health', self.CRITICAL, message="Traefik endpoint unreachable") except Exception as e: - self.service_check('traefik.health', self.UNKNOW, tags=None, message="Unknow exception" + str(e)) \ No newline at end of file + self.service_check('traefik.health', self.UNKNOWN, message="UNKNOWN exception" + str(e)) \ No newline at end of file diff --git a/traefik/tox.ini b/traefik/tox.ini index 27c23194e3..d41cb1d770 100644 --- a/traefik/tox.ini +++ b/traefik/tox.ini @@ -4,7 +4,7 @@ basepython = py27 envlist = unit, flake8 [testenv] -platform = linux2|darwin +platform = linux2|darwin|win32 deps = datadog-checks-base -rrequirements-dev.txt @@ -26,4 +26,5 @@ commands = flake8 . [flake8] exclude = .eggs,.tox +ignore = W292,E226,E501,F401,E303 max-line-length = 120