Skip to content

Commit

Permalink
Merge 74aa912 into 0f3eb04
Browse files Browse the repository at this point in the history
  • Loading branch information
jschrama authored Nov 6, 2018
2 parents 0f3eb04 + 74aa912 commit 076a226
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/collectors/redisstat/redisstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,26 @@ def collect_instance(self, nick, host, port, unix_socket, auth):

# Role needs to be handled outside the the _KEYS dict
# since the value is a string, not a int / float
# Also, master_sync_in_progress is only available if the
# redis instance is a slave, so default it here so that
# the metric is cleared if the instance flips from slave
# to master
# Also, master_sync_in_progress and master_link_status
# are only available if the redis instance is a slave,
# so default it here so that the metric is cleared if
# the instance flips from slave to master
if 'role' in info:
if info['role'] == "master":
data['replication.master'] = 1
data['replication.master_sync_in_progress'] = 0
data['replication.master_link_status'] = 0
else:
data['replication.master'] = 0

# Master link status needs to be handled outside the
# _KEYS dict since the value is a string, not a int / float
if 'master_link_status' in info:
if info['master_link_status'] == 'up':
data['replication.master_link_status'] = 1
else:
data['replication.master_link_status'] = 0

# Connect to redis and get the maxmemory config value
# Then calculate the % maxmemory of memory used
maxmemory_config = self._get_config(host, port, unix_socket, auth,
Expand Down
1 change: 1 addition & 0 deletions src/collectors/redisstat/test/testredisstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def test_real_data(self, publish_mock):

metrics = {'6379.process.uptime': 95732,
'6379.replication.master': 1,
'6379.replication.master_link_status': 0,
'6379.replication.master_sync_in_progress': 0,
'6379.pubsub.channels': 1,
'6379.slaves.connected': 2,
Expand Down

0 comments on commit 076a226

Please sign in to comment.