diff options
Diffstat (limited to '')
-rw-r--r-- | collectors/python.d.plugin/portcheck/Makefile.inc | 13 | ||||
-rw-r--r-- | collectors/python.d.plugin/portcheck/README.md | 35 | ||||
-rw-r--r-- | collectors/python.d.plugin/portcheck/portcheck.chart.py (renamed from python.d/portcheck.chart.py) | 12 | ||||
-rw-r--r-- | collectors/python.d.plugin/portcheck/portcheck.conf (renamed from conf.d/python.d/portcheck.conf) | 0 |
4 files changed, 55 insertions, 5 deletions
diff --git a/collectors/python.d.plugin/portcheck/Makefile.inc b/collectors/python.d.plugin/portcheck/Makefile.inc new file mode 100644 index 000000000..76763f02f --- /dev/null +++ b/collectors/python.d.plugin/portcheck/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 += portcheck/portcheck.chart.py +dist_pythonconfig_DATA += portcheck/portcheck.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += portcheck/README.md portcheck/Makefile.inc + diff --git a/collectors/python.d.plugin/portcheck/README.md b/collectors/python.d.plugin/portcheck/README.md new file mode 100644 index 000000000..f1338d576 --- /dev/null +++ b/collectors/python.d.plugin/portcheck/README.md @@ -0,0 +1,35 @@ +# portcheck + +Module monitors a remote TCP service. + +Following charts are drawn per host: + +1. **Latency** ms + * Time required to connect to a TCP port. + Displays latency in 0.1 ms resolution. If the connection failed, the value is missing. + +2. **Status** boolean + * Connection successful + * Could not create socket: possible DNS problems + * Connection refused: port not listening or blocked + * Connection timed out: host or port unreachable + + +### configuration + +```yaml +server: + host: 'dns or ip' # required + port: 22 # required + timeout: 1 # optional + update_every: 1 # optional +``` + +### notes + + * The error chart is 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. + * Currently, the accuracy of the latency is low and should be used as reference only. + +--- diff --git a/python.d/portcheck.chart.py b/collectors/python.d.plugin/portcheck/portcheck.chart.py index 0a312210d..e86f82544 100644 --- a/python.d/portcheck.chart.py +++ b/collectors/python.d.plugin/portcheck/portcheck.chart.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Description: simple port check netdata python.d module # Original Author: ccremer (github.com/ccremer) +# SPDX-License-Identifier: GPL-3.0-or-later import socket @@ -36,7 +37,8 @@ CHARTS = { [PORT_SUCCESS, 'success', 'absolute'], [PORT_TIMEOUT, 'timeout', 'absolute'], [PORT_FAILED, 'no connection', 'absolute'] - ]} + ] + } } @@ -56,13 +58,13 @@ class Service(SimpleService): :return: boolean """ if self.host is None or self.port is None: - self.error("Host or port missing") + self.error('Host or port missing') return False if not isinstance(self.port, int): self.error('"port" is not an integer. Specify a numerical value, not service name.') return False - self.debug("Enabled portcheck: {host}:{port}, update every {update}s, timeout: {timeout}s".format( + self.debug('Enabled portcheck: {host}:{port}, update every {update}s, timeout: {timeout}s'.format( host=self.host, port=self.port, update=self.update_every, timeout=self.timeout )) # We will accept any (valid-ish) configuration, even if initial connection fails (a service might be down from @@ -101,7 +103,7 @@ class Service(SimpleService): return data def _create_socket(self, socket_config): - af, sock_type, proto, canon_name, sa = socket_config + af, sock_type, proto, _, sa = socket_config try: self.debug('Creating socket to "{address}", port {port}'.format(address=sa[0], port=sa[1])) sock = socket.socket(af, sock_type, proto) @@ -119,7 +121,7 @@ class Service(SimpleService): :return: dict """ - af, sock_type, proto, canon_name, sa = socket_config + af, _, proto, _, sa = socket_config port = str(sa[1]) try: self.debug('Connecting socket to "{address}", port {port}'.format(address=sa[0], port=port)) diff --git a/conf.d/python.d/portcheck.conf b/collectors/python.d.plugin/portcheck/portcheck.conf index b3dd8bd3f..b3dd8bd3f 100644 --- a/conf.d/python.d/portcheck.conf +++ b/collectors/python.d.plugin/portcheck/portcheck.conf |