summaryrefslogtreecommitdiffstats
path: root/collectors/python.d.plugin
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-10-26 08:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-10-26 08:29:10 +0000
commit66ae4baad173098544603718e9864f0da1c0c7a3 (patch)
treed8e6f387ee9b4d9b6936e3c21208e50b86daea60 /collectors/python.d.plugin
parentAdding upstream version 1.18.0. (diff)
downloadnetdata-66ae4baad173098544603718e9864f0da1c0c7a3.tar.xz
netdata-66ae4baad173098544603718e9864f0da1c0c7a3.zip
Adding upstream version 1.18.1.upstream/1.18.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/python.d.plugin')
-rw-r--r--collectors/python.d.plugin/megacli/megacli.chart.py4
-rw-r--r--collectors/python.d.plugin/python_modules/bases/FrameworkServices/SimpleService.py2
-rw-r--r--collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py18
-rw-r--r--collectors/python.d.plugin/springboot/README.md2
-rw-r--r--collectors/python.d.plugin/unbound/unbound.chart.py92
5 files changed, 78 insertions, 40 deletions
diff --git a/collectors/python.d.plugin/megacli/megacli.chart.py b/collectors/python.d.plugin/megacli/megacli.chart.py
index 3805a100e..4872eab80 100644
--- a/collectors/python.d.plugin/megacli/megacli.chart.py
+++ b/collectors/python.d.plugin/megacli/megacli.chart.py
@@ -163,8 +163,8 @@ class Battery:
class Megacli:
def __init__(self):
self.s = find_binary('sudo')
- self.m = find_binary('megacli')
- self.sudo_check = [self.s, '-n', '-v']
+ self.m = find_binary('megacli') or find_binary('MegaCli') # Binary on FreeBSD is MegaCli
+ self.sudo_check = [self.s, '-n', '-l']
self.disk_info = [self.s, '-n', self.m, '-LDPDInfo', '-aAll', '-NoLog']
self.battery_info = [self.s, '-n', self.m, '-AdpBbuCmd', '-a0', '-NoLog']
diff --git a/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SimpleService.py b/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SimpleService.py
index 088bf119e..4dfd226b0 100644
--- a/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SimpleService.py
+++ b/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SimpleService.py
@@ -230,7 +230,7 @@ class SimpleService(PythonDLimitedLogger, object):
continue
elif self.charts.cleanup and chart.penalty >= self.charts.cleanup:
chart.obsolete()
- self.error("chart '{0}' was suppressed due to non updating".format(chart.name))
+ self.info("chart '{0}' was suppressed due to non updating".format(chart.name))
continue
ok = chart.update(data, interval)
diff --git a/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py b/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py
index 3b94fcdf2..337bf57d8 100644
--- a/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py
+++ b/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py
@@ -14,6 +14,12 @@ except ImportError:
else:
_TLS_SUPPORT = True
+if _TLS_SUPPORT:
+ try:
+ PROTOCOL_TLS = ssl.PROTOCOL_TLS
+ except AttributeError:
+ PROTOCOL_TLS = ssl.PROTOCOL_SSLv23
+
from bases.FrameworkServices.SimpleService import SimpleService
@@ -80,15 +86,18 @@ class SocketService(SimpleService):
if self.tls:
try:
self.debug('Encapsulating socket with TLS')
+ self.debug('Using keyfile: {0}, certfile: {1}, cert_reqs: {2}, ssl_version: {3}'.format(
+ self.key, self.cert, ssl.CERT_NONE, PROTOCOL_TLS
+ ))
self._sock = ssl.wrap_socket(self._sock,
keyfile=self.key,
certfile=self.cert,
server_side=False,
cert_reqs=ssl.CERT_NONE,
- ssl_version=ssl.PROTOCOL_TLS,
+ ssl_version=PROTOCOL_TLS,
)
- except (socket.error, ssl.SSLError) as error:
- self.error('failed to wrap socket : {0}'.format(error))
+ except (socket.error, ssl.SSLError, IOError, OSError) as error:
+ self.error('failed to wrap socket : {0}'.format(repr(error)))
self._disconnect()
self.__socket_config = None
return False
@@ -167,7 +176,8 @@ class SocketService(SimpleService):
if self._connect2socket(res):
break
- except Exception:
+ except Exception as error:
+ self.error('unhandled exception during connect : {0}'.format(repr(error)))
self._sock = None
self.__socket_config = None
diff --git a/collectors/python.d.plugin/springboot/README.md b/collectors/python.d.plugin/springboot/README.md
index 75cfa22ee..37b4dd7cb 100644
--- a/collectors/python.d.plugin/springboot/README.md
+++ b/collectors/python.d.plugin/springboot/README.md
@@ -63,7 +63,7 @@ public class HeapPoolMetrics implements PublicMetrics {
}
```
-Please refer [Spring Boot Actuator: Production-ready features](https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready.html) and [81. Actuator - Part IX. ‘How-to’ guides](https://docs.spring.io/spring-boot/docs/current/reference/html/howto-actuator.html) for more information.
+Please refer [Spring Boot Actuator: Production-ready Features](https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html#production-ready) and [81. Actuator - Part IX. ‘How-to’ guides](https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-actuator) for more information.
## Charts
diff --git a/collectors/python.d.plugin/unbound/unbound.chart.py b/collectors/python.d.plugin/unbound/unbound.chart.py
index 6e5a22c58..590de4c98 100644
--- a/collectors/python.d.plugin/unbound/unbound.chart.py
+++ b/collectors/python.d.plugin/unbound/unbound.chart.py
@@ -32,10 +32,10 @@ CHARTS = {
]
},
'recursion': {
- 'options': [None, 'Recursion Timings', 'seconds', 'Unbound', 'unbound.recursion', 'line'],
+ 'options': [None, 'Recursion Timings', 'milliseconds', 'Unbound', 'unbound.recursion', 'line'],
'lines': [
- ['recursive_avg', 'average', 'absolute', 1, PRECISION],
- ['recursive_med', 'median', 'absolute', 1, PRECISION]
+ ['recursive_avg', 'average', 'absolute', 1, 1],
+ ['recursive_med', 'median', 'absolute', 1, 1]
]
},
'reqlist': {
@@ -83,11 +83,11 @@ PER_THREAD_CHARTS = {
]
},
'_recursion': {
- 'options': [None, '{longname} Recursion Timings', 'seconds', 'Recursive Timings',
+ 'options': [None, '{longname} Recursion Timings', 'milliseconds', 'Recursive Timings',
'unbound.threads.recursion', 'line'],
'lines': [
- ['{shortname}_recursive_avg', 'average', 'absolute', 1, PRECISION],
- ['{shortname}_recursive_med', 'median', 'absolute', 1, PRECISION]
+ ['{shortname}_recursive_avg', 'average', 'absolute', 1, 1],
+ ['{shortname}_recursive_med', 'median', 'absolute', 1, 1]
]
},
'_reqlist': {
@@ -103,7 +103,6 @@ PER_THREAD_CHARTS = {
}
}
-
# This maps the Unbound stat names to our names and precision requiremnets.
STAT_MAP = {
'total.num.queries_ip_ratelimited': ('ratelimit', 1),
@@ -118,6 +117,7 @@ STAT_MAP = {
'total.requestlist.exceeded': ('reqlist_exceeded', 1),
'total.requestlist.current.all': ('reqlist_current', 1),
'total.requestlist.current.user': ('reqlist_user', 1),
+ # Unbound reports recursion timings as fractional seconds, but we want to show them as milliseconds.
'total.recursion.time.avg': ('recursive_avg', PRECISION),
'total.recursion.time.median': ('recursive_med', PRECISION),
'msg.cache.count': ('cache_message', 1),
@@ -142,11 +142,16 @@ PER_THREAD_STAT_MAP = {
'{shortname}.requestlist.exceeded': ('{shortname}_reqlist_exceeded', 1),
'{shortname}.requestlist.current.all': ('{shortname}_reqlist_current', 1),
'{shortname}.requestlist.current.user': ('{shortname}_reqlist_user', 1),
+ # Unbound reports recursion timings as fractional seconds, but we want to show them as milliseconds.
'{shortname}.recursion.time.avg': ('{shortname}_recursive_avg', PRECISION),
'{shortname}.recursion.time.median': ('{shortname}_recursive_med', PRECISION)
}
+def is_readable(name):
+ return os.access(name, os.R_OK)
+
+
# Used to actually generate per-thread charts.
def _get_perthread_info(thread):
sname = 'thread{0}'.format(thread)
@@ -203,25 +208,8 @@ class Service(SocketService):
self.debug('Using certificate: {0}'.format(self.cert))
def _auto_config(self):
- if self.ubconf and os.access(self.ubconf, os.R_OK):
- self.debug('Unbound config: {0}'.format(self.ubconf))
- conf = dict()
- try:
- conf = load_config(self.ubconf)
- except Exception as error:
- self.error("error on loading '{0}' : {1}".format(self.ubconf, error))
- if self.ext is None:
- if 'extended-statistics' in conf['server']:
- self.ext = conf['server']['extended-statistics']
- if 'remote-control' in conf:
- if conf['remote-control'].get('control-use-cert', False):
- self.key = self.key or conf['remote-control'].get('control-key-file')
- self.cert = self.cert or conf['remote-control'].get('control-cert-file')
- self.port = self.port or conf['remote-control'].get('control-port')
- else:
- self.unix_socket = self.unix_socket or conf['remote-control'].get('control-interface')
- else:
- self.debug('Unbound configuration not found.')
+ self.load_unbound_config()
+
if not self.key:
self.key = '/etc/unbound/unbound_control.key'
if not self.cert:
@@ -229,6 +217,38 @@ class Service(SocketService):
if not self.port:
self.port = 8953
+ def load_unbound_config(self):
+ if not (self.ubconf and is_readable(self.ubconf)):
+ self.debug('Unbound configuration not found.')
+ return
+
+ self.debug('Loading Unbound config: {0}'.format(self.ubconf))
+
+ try:
+ conf = load_config(self.ubconf)
+ except Exception as error:
+ self.error("error on loading '{0}' : {1}".format(self.ubconf, error))
+ return
+
+ srv = conf.get('server')
+ if self.ext is None:
+ if srv and 'extended-statistics' in srv:
+ self.ext = srv['extended-statistics']
+
+ rc = conf.get('remote-control')
+ if not (rc and isinstance(rc, dict)):
+ return
+
+ if rc.get('control-use-cert', False):
+ self.key = self.key or rc.get('control-key-file')
+ self.cert = self.cert or rc.get('control-cert-file')
+ self.port = self.port or rc.get('control-port')
+ else:
+ ci = rc.get('control-interface', str())
+ is_socket = '/' in ci
+ if is_socket:
+ self.unix_socket = ci
+
def _generate_perthread_charts(self):
tmporder = list()
for thread in range(0, self.threads):
@@ -239,6 +259,14 @@ class Service(SocketService):
self.order.extend(sorted(tmporder))
def check(self):
+ if not is_readable(self.key):
+ self.error("ssl key '{0}' is not readable".format(self.key))
+ return False
+
+ if not is_readable(self.cert):
+ self.error("ssl certificate '{0}' is not readable".format(self.certificate))
+ return False
+
# Check if authentication is working.
self._connect()
result = bool(self._sock)
@@ -268,12 +296,6 @@ class Service(SocketService):
self.request = tmp
return result
- @staticmethod
- def _check_raw_data(data):
- # The server will close the connection when it's done sending
- # data, so just keep looping until that happens.
- return False
-
def _get_data(self):
raw = self._get_raw_data()
data = dict()
@@ -288,3 +310,9 @@ class Service(SocketService):
else:
self.warning('Received no data from socket.')
return data
+
+ @staticmethod
+ def _check_raw_data(data):
+ # The server will close the connection when it's done sending
+ # data, so just keep looping until that happens.
+ return False