summaryrefslogtreecommitdiffstats
path: root/collectors/python.d.plugin/rethinkdbs/rethinkdbs.chart.py
diff options
context:
space:
mode:
Diffstat (limited to 'collectors/python.d.plugin/rethinkdbs/rethinkdbs.chart.py')
-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,