Skip to content

Instantly share code, notes, and snippets.

@moritzheiber
Created October 10, 2012 08:04
Show Gist options
  • Select an option

  • Save moritzheiber/3863937 to your computer and use it in GitHub Desktop.

Select an option

Save moritzheiber/3863937 to your computer and use it in GitHub Desktop.
ruby mysql checker
require 'rubygems'
require 'mysql2'
client = Mysql2::Client.new(:host => '127.0.0.1',:username => 'checker',:password => 'checker')
client.query("show slave status").each do |r|
lag = r['Seconds_Behind_Master']
io = r['Slave_IO_Running']
puts "row = #{r}"
puts "lag = #{lag}"
puts "io = #{io}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment