Skip to content

Commit

Permalink
Merge pull request #1755 from DataDog/quentin/redis-elasticache
Browse files Browse the repository at this point in the history
[redis] handle exception when CONFIG disabled
  • Loading branch information
Remi Hakim committed Jul 27, 2015
2 parents 28a1595 + c8afec8 commit 6a6dc3c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions checks.d/redisdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,15 @@ def _check_slowlog(self, instance, custom_tags):
tags, _ = self._get_tags(custom_tags, instance)

if not instance.get(MAX_SLOW_ENTRIES_KEY):
max_slow_entries = int(conn.config_get(MAX_SLOW_ENTRIES_KEY)[MAX_SLOW_ENTRIES_KEY])
if max_slow_entries > DEFAULT_MAX_SLOW_ENTRIES:
self.warning("Redis {0} is higher than {1}. Defaulting to {1}."
"If you need a higher value, please set {0} in your check config"
.format(MAX_SLOW_ENTRIES_KEY, DEFAULT_MAX_SLOW_ENTRIES))
try:
max_slow_entries = int(conn.config_get(MAX_SLOW_ENTRIES_KEY)[MAX_SLOW_ENTRIES_KEY])
if max_slow_entries > DEFAULT_MAX_SLOW_ENTRIES:
self.warning("Redis {0} is higher than {1}. Defaulting to {1}."
"If you need a higher value, please set {0} in your check config"
.format(MAX_SLOW_ENTRIES_KEY, DEFAULT_MAX_SLOW_ENTRIES))
max_slow_entries = DEFAULT_MAX_SLOW_ENTRIES
# No config on AWS Elasticache
except redis.ResponseError:
max_slow_entries = DEFAULT_MAX_SLOW_ENTRIES
else:
max_slow_entries = int(instance.get(MAX_SLOW_ENTRIES_KEY))
Expand Down

0 comments on commit 6a6dc3c

Please sign in to comment.