-
-
Save goguelu/150364 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'active_record' | |
require 'active_support' | |
require 'parseconfig' | |
config = ParseConfig.new( '/path/to/conf/file.conf' ) | |
db_number = Integer(config.get_value( 'database_count' )) | |
db_parameters = (1...db_number +1).collect do |i| | |
config.get_value("DB#{i}")[1..-2].split(',') | |
end | |
counts = db_parameters.collect do |params| | |
ActiveRecord::Base.establish_connection( | |
:adapter => params[0], | |
:host => params[1], | |
:port => Integer(params[2]), | |
:database => params[3], | |
:username => params[4], | |
:password => params[5] | |
) | |
class Order < ActiveRecord::Base | |
set_table_name "Orders" | |
end | |
Order.count('ID') | |
end | |
if counts.all? { |c| c == counts.first } | |
puts "OK" | |
exit 0 | |
else | |
results = counts.to_a | |
db_parameters.each do |params| | |
print params[6] + " " + results[db_parameters.index(params)].to_s + " " | |
end | |
exit 2 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment