Skip to content

Commit

Permalink
check master redis for n connected slaves
Browse files Browse the repository at this point in the history
  • Loading branch information
C. Flores committed Oct 2, 2011
1 parent 445e474 commit 8f2cd76
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions redis_replication_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
opts.on( '-r', '--role <master|slave>', 'redis should be master or slave' ) do |role|
options[:role] = role.to_s
end
options[:connectedslaves] = nil
options[:connected_slaves] = nil
opts.on( '-c', '--connected_slaves <int>', 'master should have <int> slaves. must be used with -r/--role master. defaults to 1' ) do |int|
options[:connected_slaves] = int.to_i
end
Expand Down Expand Up @@ -88,22 +88,22 @@
if options[:role] == "slave"
expectedlag = options[:slave_lag].to_i || 0
if status["role"] =~ /slave/ \
and status["master_link_status"] =~ /up/ \
and status["master_last_io_seconds_ago"].to_i <= expectedlag
&& status["master_link_status"] =~ /up/ \
&& status["master_last_io_seconds_ago"].to_i <= expectedlag

puts "status ok ok"
else
puts "status err redis thinks it is #{status["role"]}, master is #{status["master_link_status"]} and last io was #{status["master_last_io_seconds_ago"]}s."
end
puts "metric master_last_io_seconds_ago int #{status["master_last_io_seconds_ago"]}"
else
expectedslaves = options[:connected_slaves].to_i || 1
if status["role"] =~ /master/ \
and status["connected_slaves"].to_i = expectedslaves
expectedslaves = options[:connected_slaves] || 1
actualslaves = status["connected_slaves"].to_i
if status["role"] =~ /master/ && actualslaves == expectedslaves

puts "status ok ok"
else
puts "status err redis thinks it is #{status["role"]} with #{status["connected_slaves"].to_i} slaves."
puts "status err redis thinks it is #{status["role"]} with #{actualslaves} slaves."
end
end

0 comments on commit 8f2cd76

Please sign in to comment.