Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/ruby
- require 'mysql'
- EXCLUDE_DATABASES = [
- 'information_schema',
- 'performance_schema',
- ]
- host = ARGV[0]
- user = ARGV[1]
- password = ARGV[2]
- begin
- db = Mysql.new(host, user, password)
- rescue Mysql::Error => e
- print 'NG ' + e.message
- exit 2
- end
- errors = []
- db.query('SHOW DATABASES').each do |row_db|
- name_db = row_db[0]
- next if EXCLUDE_DATABASES.member?(name_db)
- db.query("USE `#{name_db}`")
- db.query('SHOW TABLES').each do |row_table|
- name_table = row_table[0]
- status = false
- db.query("CHECK TABLE `#{name_table}`").each do |row_check|
- if (row_check[2] == 'status') and (row_check[3] == 'OK')
- status = true
- break
- end
- end
- unless status
- errors.push("#{name_db}.#{name_table}")
- end
- end
- end
- db.close
- if errors.empty?
- print 'OK'
- exit 0
- else
- print "NG #{errors.join(' ')}"
- exit 2
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement