summaryrefslogtreecommitdiffstats
path: root/collectors/python.d.plugin
diff options
context:
space:
mode:
Diffstat (limited to 'collectors/python.d.plugin')
-rw-r--r--collectors/python.d.plugin/mongodb/mongodb.conf10
-rw-r--r--collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py4
-rw-r--r--collectors/python.d.plugin/rethinkdbs/rethinkdbs.chart.py17
-rw-r--r--collectors/python.d.plugin/sensors/sensors.chart.py2
-rw-r--r--collectors/python.d.plugin/smartd_log/smartd_log.chart.py12
-rw-r--r--collectors/python.d.plugin/unbound/unbound.chart.py37
6 files changed, 53 insertions, 29 deletions
diff --git a/collectors/python.d.plugin/mongodb/mongodb.conf b/collectors/python.d.plugin/mongodb/mongodb.conf
index 53858ae2..2dded40a 100644
--- a/collectors/python.d.plugin/mongodb/mongodb.conf
+++ b/collectors/python.d.plugin/mongodb/mongodb.conf
@@ -84,9 +84,9 @@ local:
port : 27017
# authsample:
-# name : 'secure'
-# host : 'mongodb.example.com'
-# port : 27017
+# name : 'secure'
+# host : 'mongodb.example.com'
+# port : 27017
# authdb : 'admin'
-# user : 'monitor'
-# password : 'supersecret'
+# user : 'monitor'
+# pass : 'supersecret'
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 27519b76..3b94fcdf 100644
--- a/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py
+++ b/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py
@@ -4,6 +4,7 @@
# Author: Ilya Mashchenko (ilyam8)
# SPDX-License-Identifier: GPL-3.0-or-later
+import errno
import socket
try:
@@ -181,7 +182,8 @@ class SocketService(SimpleService):
self._sock.shutdown(2) # 0 - read, 1 - write, 2 - all
self._sock.close()
except Exception as error:
- self.error(error)
+ if not (hasattr(error, 'errno') and error.errno == errno.ENOTCONN):
+ self.error(error)
self._sock = None
def _send(self, request=None):
diff --git a/collectors/python.d.plugin/rethinkdbs/rethinkdbs.chart.py b/collectors/python.d.plugin/rethinkdbs/rethinkdbs.chart.py
index ee2fb68b..80cc1cf1 100644
--- a/collectors/python.d.plugin/rethinkdbs/rethinkdbs.chart.py
+++ b/collectors/python.d.plugin/rethinkdbs/rethinkdbs.chart.py
@@ -131,6 +131,15 @@ class Server:
return dict(('{0}_{1}'.format(self.name, k), d[k]) for k in d)
+# https://pypi.org/project/rethinkdb/2.4.0/
+# rdb.RethinkDB() can be used as rdb drop in replacement.
+# https://github.com/rethinkdb/rethinkdb-python#quickstart
+def get_rethinkdb():
+ if hasattr(rdb, 'RethinkDB'):
+ return rdb.RethinkDB()
+ return rdb
+
+
class Service(SimpleService):
def __init__(self, configuration=None, name=None):
SimpleService.__init__(self, configuration=configuration, name=name)
@@ -141,6 +150,7 @@ class Service(SimpleService):
self.user = self.configuration.get('user', 'admin')
self.password = self.configuration.get('password')
self.timeout = self.configuration.get('timeout', 2)
+ self.rdb = None
self.conn = None
self.alive = True
@@ -149,6 +159,9 @@ class Service(SimpleService):
self.error('"rethinkdb" module is needed to use rethinkdbs.py')
return False
+ self.debug("rethinkdb driver version {0}".format(rdb.__version__))
+ self.rdb = get_rethinkdb()
+
if not self.connect():
return None
@@ -196,14 +209,14 @@ class Service(SimpleService):
def get_stats(self):
try:
- return list(rdb.db('rethinkdb').table('stats').run(self.conn).items)
+ return list(self.rdb.db('rethinkdb').table('stats').run(self.conn).items)
except rdb.errors.ReqlError:
self.alive = False
return None
def connect(self):
try:
- self.conn = rdb.connect(
+ self.conn = self.rdb.connect(
host=self.host,
port=self.port,
user=self.user,
diff --git a/collectors/python.d.plugin/sensors/sensors.chart.py b/collectors/python.d.plugin/sensors/sensors.chart.py
index 02e88e6a..6b54ea60 100644
--- a/collectors/python.d.plugin/sensors/sensors.chart.py
+++ b/collectors/python.d.plugin/sensors/sensors.chart.py
@@ -92,7 +92,7 @@ class Service(SimpleService):
SimpleService.__init__(self, configuration=configuration, name=name)
self.order = list()
self.definitions = dict()
- self.chips = list()
+ self.chips = configuration.get('chips')
def get_data(self):
data = dict()
diff --git a/collectors/python.d.plugin/smartd_log/smartd_log.chart.py b/collectors/python.d.plugin/smartd_log/smartd_log.chart.py
index 12f756c5..f121ab2e 100644
--- a/collectors/python.d.plugin/smartd_log/smartd_log.chart.py
+++ b/collectors/python.d.plugin/smartd_log/smartd_log.chart.py
@@ -558,6 +558,7 @@ class DiskLogFile:
class BaseDisk:
def __init__(self, name, log_file):
+ self.raw_name = name
self.name = re.sub(r'_+', '_', name)
self.log_file = log_file
self.attrs = list()
@@ -566,8 +567,8 @@ class BaseDisk:
def __eq__(self, other):
if isinstance(other, BaseDisk):
- return self.name == other.name
- return self.name == other
+ return self.raw_name == other.raw_name
+ return self.raw_name == other
def __ne__(self, other):
return not self == other
@@ -657,7 +658,7 @@ class Service(SimpleService):
not disk.log_file.is_active(current_time, self.age),
]
):
- self.disks.remove(disk.name)
+ self.disks.remove(disk.raw_name)
self.remove_disk_from_charts(disk)
def scan(self):
@@ -681,9 +682,11 @@ class Service(SimpleService):
path = os.path.join(self.log_path, full_name)
if name in self.disks:
+ self.debug('skipping {0}: already in disks'.format(full_name))
return None
if [p for p in self.exclude if p in name]:
+ self.debug('skipping {0}: filtered by `exclude` option'.format(full_name))
return None
if not os.access(path, os.R_OK):
@@ -747,5 +750,4 @@ class Service(SimpleService):
if not chart_id or chart_id not in self.charts:
continue
- # TODO: can't delete dimension
- self.charts[chart_id].hide_dimension('{0}_{1}'.format(disk.name, attr.name))
+ self.charts[chart_id].del_dimension('{0}_{1}'.format(disk.name, attr.name))
diff --git a/collectors/python.d.plugin/unbound/unbound.chart.py b/collectors/python.d.plugin/unbound/unbound.chart.py
index dade2b20..6e5a22c5 100644
--- a/collectors/python.d.plugin/unbound/unbound.chart.py
+++ b/collectors/python.d.plugin/unbound/unbound.chart.py
@@ -253,15 +253,19 @@ class Service(SocketService):
else:
self.request = b'UBCT1 status\n'
raw = self._get_raw_data()
- for line in raw.splitlines():
- if line.startswith('threads'):
- self.threads = int(line.split()[1])
- self._generate_perthread_charts()
- break
- if self.threads is None:
- self.info('Unable to auto-detect thread counts, disabling per-thread stats.')
- self.perthread = False
- self.request = tmp
+ if raw is None:
+ result = False
+ self.warning('Received no data from socket.')
+ else:
+ for line in raw.splitlines():
+ if line.startswith('threads'):
+ self.threads = int(line.split()[1])
+ self._generate_perthread_charts()
+ break
+ if self.threads is None:
+ self.info('Unable to auto-detect thread counts, disabling per-thread stats.')
+ self.perthread = False
+ self.request = tmp
return result
@staticmethod
@@ -274,10 +278,13 @@ class Service(SocketService):
raw = self._get_raw_data()
data = dict()
tmp = dict()
- for line in raw.splitlines():
- stat = line.split('=')
- tmp[stat[0]] = stat[1]
- for item in self.statmap:
- if item in tmp:
- data[self.statmap[item][0]] = float(tmp[item]) * self.statmap[item][1]
+ if raw is not None:
+ for line in raw.splitlines():
+ stat = line.split('=')
+ tmp[stat[0]] = stat[1]
+ for item in self.statmap:
+ if item in tmp:
+ data[self.statmap[item][0]] = float(tmp[item]) * self.statmap[item][1]
+ else:
+ self.warning('Received no data from socket.')
return data