summaryrefslogtreecommitdiffstats
path: root/python.d/redis.chart.py
diff options
context:
space:
mode:
authorFederico Ceratto <federico.ceratto@gmail.com>2017-12-19 23:39:27 +0000
committerFederico Ceratto <federico.ceratto@gmail.com>2017-12-19 23:39:27 +0000
commit6abdfdead1326ccca98dc4cf415c216f1bf25400 (patch)
tree70b803bd499fd45e89627c1b45b90ddf20e8e959 /python.d/redis.chart.py
parentRelease v. 1.8.0+dfsg-1 to Unstable (diff)
parentNew upstream version 1.9.0+dfsg (diff)
downloadnetdata-6abdfdead1326ccca98dc4cf415c216f1bf25400.tar.xz
netdata-6abdfdead1326ccca98dc4cf415c216f1bf25400.zip
Update upstream source from tag 'upstream/1.9.0+dfsg'
Update to upstream version '1.9.0+dfsg' with Debian dir 28b8242a05f9ad26cd1cdbcf078be754fc7d6251
Diffstat (limited to 'python.d/redis.chart.py')
-rw-r--r--python.d/redis.chart.py33
1 files changed, 25 insertions, 8 deletions
diff --git a/python.d/redis.chart.py b/python.d/redis.chart.py
index 7c3c43f5a..bcfcf16a6 100644
--- a/python.d/redis.chart.py
+++ b/python.d/redis.chart.py
@@ -2,10 +2,9 @@
# Description: redis netdata python.d module
# Author: Pawel Krupa (paulfantom)
-from base import SocketService
+from bases.FrameworkServices.SocketService import SocketService
# default module values (can be overridden per job in `config`)
-#update_every = 2
priority = 60000
retries = 60
@@ -19,7 +18,8 @@ retries = 60
# 'unix_socket': None
# }}
-ORDER = ['operations', 'hit_rate', 'memory', 'keys', 'net', 'connections', 'clients', 'slaves', 'persistence']
+ORDER = ['operations', 'hit_rate', 'memory', 'keys', 'net', 'connections', 'clients', 'slaves', 'persistence',
+ 'bgsave_now', 'bgsave_health']
CHARTS = {
'operations': {
@@ -72,6 +72,18 @@ CHARTS = {
'redis.rdb_changes', 'line'],
'lines': [
['rdb_changes_since_last_save', 'changes', 'absolute']
+ ]},
+ 'bgsave_now': {
+ 'options': [None, 'Duration of the RDB Save Operation', 'seconds', 'persistence',
+ 'redis.bgsave_now', 'absolute'],
+ 'lines': [
+ ['rdb_bgsave_in_progress', 'rdb save', 'absolute']
+ ]},
+ 'bgsave_health': {
+ 'options': [None, 'Status of the Last RDB Save Operation', 'status', 'persistence',
+ 'redis.bgsave_health', 'line'],
+ 'lines': [
+ ['rdb_last_bgsave_status', 'rdb save', 'absolute']
]}
}
@@ -87,6 +99,7 @@ class Service(SocketService):
self.port = self.configuration.get('port', 6379)
self.unix_socket = self.configuration.get('socket')
password = self.configuration.get('pass', str())
+ self.bgsave_time = 0
self.requests = dict(request='INFO\r\n'.encode(),
password=' '.join(['AUTH', password, '\r\n']).encode() if password else None)
self.request = self.requests['request']
@@ -130,9 +143,8 @@ class Service(SocketService):
data[t[0]] = t[1]
except (IndexError, ValueError):
self.debug("invalid line received: " + str(line))
- pass
- if len(data) == 0:
+ if not data:
self.error("received data doesn't have any records")
return None
@@ -142,6 +154,14 @@ class Service(SocketService):
except (KeyError, ZeroDivisionError, TypeError):
data['hit_rate'] = 0
+ if data['rdb_bgsave_in_progress'] != '0\r':
+ self.bgsave_time += self.update_every
+ else:
+ self.bgsave_time = 0
+
+ data['rdb_last_bgsave_status'] = 0 if data['rdb_last_bgsave_status'] == 'ok\r' else 1
+ data['rdb_bgsave_in_progress'] = self.bgsave_time
+
return data
def _check_raw_data(self, data):
@@ -170,9 +190,6 @@ class Service(SocketService):
Parse configuration, check if redis is available, and dynamically create chart lines data
:return: boolean
"""
- if self.name == "":
- self.name = "local"
- self.chart_name += "_" + self.name
data = self._get_data()
if data is None:
return False