Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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
Add Comment
Please, Sign In to add comment