summaryrefslogtreecommitdiffstats
path: root/collectors/python.d.plugin/rethinkdbs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-08-04 08:56:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-08-04 08:56:44 +0000
commit34f488f41ee820371159111bf621f11d0f54f669 (patch)
tree13eea1c3aa3d905ec929691bbf23d8b90bef1dcb /collectors/python.d.plugin/rethinkdbs
parentAdding upstream version 1.16.0. (diff)
downloadnetdata-34f488f41ee820371159111bf621f11d0f54f669.tar.xz
netdata-34f488f41ee820371159111bf621f11d0f54f669.zip
Adding upstream version 1.16.1.upstream/1.16.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--collectors/python.d.plugin/rethinkdbs/rethinkdbs.chart.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/collectors/python.d.plugin/rethinkdbs/rethinkdbs.chart.py b/collectors/python.d.plugin/rethinkdbs/rethinkdbs.chart.py
index ee2fb68b3..80cc1cf18 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,