Guest User

Untitled

a guest
Mar 9th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #!/usr/bin/ruby
  2.  
  3. require 'rubygems'
  4. require 'active_record'
  5. require 'active_support'
  6. require 'parseconfig'
  7.  
  8. config = ParseConfig.new( '/path/to/conf/file.conf' )
  9. db_number = Integer(config.get_value( 'database_count' ))
  10.  
  11. db_parameters = (1...db_number +1).collect do |i|
  12. config.get_value("DB#{i}")[1..-2].split(',')
  13. end
  14.  
  15. counts = db_parameters.collect do |params|
  16. ActiveRecord::Base.establish_connection(
  17. :adapter => params[0],
  18. :host => params[1],
  19. :port => Integer(params[2]),
  20. :database => params[3],
  21. :username => params[4],
  22. :password => params[5]
  23. )
  24.  
  25. class Order < ActiveRecord::Base
  26. set_table_name "Orders"
  27. end
  28.  
  29. Order.count('ID')
  30. end
  31.  
  32. if counts.all? { |c| c == counts.first }
  33. puts "OK"
  34. exit 0
  35. else
  36. results = counts.to_a
  37. db_parameters.each do |params|
  38. print params[6] + " " + results[db_parameters.index(params)].to_s + " "
  39. end
  40. exit 2
  41. end
Add Comment
Please, Sign In to add comment