diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2018-11-07 12:19:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2018-11-07 12:20:17 +0000 |
commit | a64a253794ac64cb40befee54db53bde17dd0d49 (patch) | |
tree | c1024acc5f6e508814b944d99f112259bb28b1be /collectors/python.d.plugin/httpcheck | |
parent | New upstream version 1.10.0+dfsg (diff) | |
download | netdata-a64a253794ac64cb40befee54db53bde17dd0d49.tar.xz netdata-a64a253794ac64cb40befee54db53bde17dd0d49.zip |
New upstream version 1.11.0+dfsgupstream/1.11.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | collectors/python.d.plugin/httpcheck/Makefile.inc | 13 | ||||
-rw-r--r-- | collectors/python.d.plugin/httpcheck/README.md | 41 | ||||
-rw-r--r-- | collectors/python.d.plugin/httpcheck/httpcheck.chart.py (renamed from python.d/httpcheck.chart.py) | 18 | ||||
-rw-r--r-- | collectors/python.d.plugin/httpcheck/httpcheck.conf (renamed from conf.d/python.d/httpcheck.conf) | 1 |
4 files changed, 66 insertions, 7 deletions
diff --git a/collectors/python.d.plugin/httpcheck/Makefile.inc b/collectors/python.d.plugin/httpcheck/Makefile.inc new file mode 100644 index 000000000..4a5bd856d --- /dev/null +++ b/collectors/python.d.plugin/httpcheck/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_python_DATA += httpcheck/httpcheck.chart.py +dist_pythonconfig_DATA += httpcheck/httpcheck.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += httpcheck/README.md httpcheck/Makefile.inc + diff --git a/collectors/python.d.plugin/httpcheck/README.md b/collectors/python.d.plugin/httpcheck/README.md new file mode 100644 index 000000000..759107663 --- /dev/null +++ b/collectors/python.d.plugin/httpcheck/README.md @@ -0,0 +1,41 @@ +# httpcheck + +Module monitors remote http server for availability and response time. + +Following charts are drawn per job: + +1. **Response time** ms + * Time in 0.1 ms resolution in which the server responds. + If the connection failed, the value is missing. + +2. **Status** boolean + * Connection successful + * Unexpected content: No Regex match found in the response + * Unexpected status code: Do we get 500 errors? + * Connection failed: port not listening or blocked + * Connection timed out: host or port unreachable + +### configuration + +Sample configuration and their default values. + +```yaml +server: + url: 'http://host:port/path' # required + status_accepted: # optional + - 200 + timeout: 1 # optional, supports decimals (e.g. 0.2) + update_every: 3 # optional + regex: 'REGULAR_EXPRESSION' # optional, see https://docs.python.org/3/howto/regex.html + redirect: yes # optional +``` + +### notes + + * The status chart is primarily intended for alarms, badges or for access via API. + * A system/service/firewall might block netdata's access if a portscan or + similar is detected. + * This plugin is meant for simple use cases. Currently, the accuracy of the + response time is low and should be used as reference only. + +--- diff --git a/python.d/httpcheck.chart.py b/collectors/python.d.plugin/httpcheck/httpcheck.chart.py index b0177ff90..f046f33c0 100644 --- a/python.d/httpcheck.chart.py +++ b/collectors/python.d.plugin/httpcheck/httpcheck.chart.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Description: http check netdata python.d module # Original Author: ccremer (github.com/ccremer) +# SPDX-License-Identifier: GPL-3.0-or-later import urllib3 import re @@ -35,12 +36,14 @@ CHARTS = { 'options': [None, 'HTTP response time', 'ms', 'response', 'httpcheck.responsetime', 'line'], 'lines': [ [HTTP_RESPONSE_TIME, 'time', 'absolute', 100, 1000] - ]}, + ] + }, 'response_length': { 'options': [None, 'HTTP response body length', 'characters', 'response', 'httpcheck.responselength', 'line'], 'lines': [ [HTTP_RESPONSE_LENGTH, 'length', 'absolute'] - ]}, + ] + }, 'status': { 'options': [None, 'HTTP status', 'boolean', 'status', 'httpcheck.status', 'line'], 'lines': [ @@ -49,7 +52,8 @@ CHARTS = { [HTTP_BAD_STATUS, 'bad status', 'absolute'], [HTTP_TIMEOUT, 'timeout', 'absolute'], [HTTP_NO_CONNECTION, 'no connection', 'absolute'] - ]} + ] + } } @@ -87,15 +91,15 @@ class Service(UrlService): self.process_response(content, data, status) except urllib3.exceptions.NewConnectionError as error: - self.debug("Connection failed: {url}. Error: {error}".format(url=url, error=error)) + self.debug('Connection failed: {url}. Error: {error}'.format(url=url, error=error)) data[HTTP_NO_CONNECTION] = 1 except (urllib3.exceptions.TimeoutError, urllib3.exceptions.PoolError) as error: - self.debug("Connection timed out: {url}. Error: {error}".format(url=url, error=error)) + self.debug('Connection timed out: {url}. Error: {error}'.format(url=url, error=error)) data[HTTP_TIMEOUT] = 1 except urllib3.exceptions.HTTPError as error: - self.debug("Connection failed: {url}. Error: {error}".format(url=url, error=error)) + self.debug('Connection failed: {url}. Error: {error}'.format(url=url, error=error)) data[HTTP_NO_CONNECTION] = 1 except (TypeError, AttributeError) as error: @@ -109,7 +113,7 @@ class Service(UrlService): self.debug('Content: \n\n{content}\n'.format(content=content)) if status in self.status_codes_accepted: if self.regex and self.regex.search(content) is None: - self.debug("No match for regex '{regex}' found".format(regex=self.regex.pattern)) + self.debug('No match for regex "{regex}" found'.format(regex=self.regex.pattern)) data[HTTP_BAD_CONTENT] = 1 else: data[HTTP_SUCCESS] = 1 diff --git a/conf.d/python.d/httpcheck.conf b/collectors/python.d.plugin/httpcheck/httpcheck.conf index 058e057a6..bd21b5af8 100644 --- a/conf.d/python.d/httpcheck.conf +++ b/collectors/python.d.plugin/httpcheck/httpcheck.conf @@ -66,6 +66,7 @@ chart_cleanup: 0 # url: 'http[s]://host-ip-or-dns[:port][path]' # # [required] the remote host url to connect to. If [:port] is missing, it defaults to 80 # # for HTTP and 443 for HTTPS. [path] is optional too, defaults to / +# method: GET # [optional] the HTTP request method (POST, PUT, DELETE, HEAD etc.) # redirect: yes # [optional] If the remote host returns 3xx status codes, the redirection url will be # # followed (default). # status_accepted: # [optional] By default, 200 is accepted. Anything else will result in 'bad status' in the |