Skip to content

Commit

Permalink
Merge branch 'haissam/redis-repl-metrics' of github.com:DataDog/dd-ag…
Browse files Browse the repository at this point in the history
…ent into haissam/redis-repl-metrics

Conflicts:
	checks.d/redisdb.py
  • Loading branch information
hkaj committed Feb 6, 2015
2 parents cb58d83 + 52d68fa commit 4d9d95e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
7 changes: 4 additions & 3 deletions checks.d/redisdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,14 @@ def _check_db(self, instance, custom_tags=None):
self.gauge('redis.key.length', 0, tags=key_tags)

# Save the replication delay for each slave
for key in info.keys():
if self.slave_key_pattern.match(key):
for key in info:
if self.slave_key_pattern.match(key) and isinstance(info[key], dict):
slave_offset = info[key].get('offset')
master_offset = info.get('master_repl_offset')
if slave_offset and master_offset and master_offset - slave_offset >= 0:
delay = master_offset - slave_offset
slave_tags = tags + [info[key]['ip']] if 'ip' in info[key].keys() else tags
slave_tags = tags + ['slave_ip:%s' % info[key]['ip']] if 'ip' in info[key] else tags
slave_tags.append('slave_id:%s' % key.lstrip('slave'))
self.gauge('redis.replication.delay.%s' % key, delay, tags=slave_tags)

def check(self, instance):
Expand Down
23 changes: 21 additions & 2 deletions ci/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,27 @@ def redis_rootdir
Rake::Task['ci:common:run_tests'].invoke(this_provides)
end

task :cleanup => ['ci:common:cleanup']
# FIXME: stop redis
task :cleanup => ['ci:common:cleanup'] do
# Shutdown redis
conf_files = ["#{ENV['TRAVIS_BUILD_DIR']}/ci/resources/redis/auth.conf",
"#{ENV['TRAVIS_BUILD_DIR']}/ci/resources/redis/noauth.conf"]
for f in conf_files do
pass, port = nil, nil
File.readlines(f).each do |line|
param = line.split(' ')
if param[0] == 'port'
port = param[1]
elsif param[0] == 'requirepass'
pass = param[1]
end
end
if pass and port
sh %(#{redis_rootdir}/src/redis-cli -p #{port} -a #{pass} SHUTDOWN)
elsif port
sh %(#{redis_rootdir}/src/redis-cli -p #{port} SHUTDOWN)
end
end
end

task :execute do
exception = nil
Expand Down
1 change: 1 addition & 0 deletions ci/resources/redis/auth.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ pidfile /tmp/dd-redis-auth.pid
bind 127.0.0.1
port 26379
requirepass datadog-is-devops-best-friend
slaveof 127.0.0.1 16379

0 comments on commit 4d9d95e

Please sign in to comment.