Module: Galera
- Included in:
- Checker
- Defined in:
- lib/apprentice/checks/galera.rb
Instance Method Summary collapse
- #check_cluster_size ⇒ Object
- #check_local_state ⇒ Object
- #check_ready_state ⇒ Object
- #get_galera_status ⇒ Object
- #run_checks ⇒ Object
Instance Method Details
#check_cluster_size ⇒ Object
35 36 37 38 |
# File 'lib/apprentice/checks/galera.rb', line 35 def check_cluster_size return true if Integer(@status['wsrep_cluster_size']) > 1 false end |
#check_local_state ⇒ Object
45 46 47 48 49 |
# File 'lib/apprentice/checks/galera.rb', line 45 def check_local_state s = Integer(@status['wsrep_local_state']) return true if s == 4 || (s == 2 && @donor_allowed) false end |
#check_ready_state ⇒ Object
40 41 42 43 |
# File 'lib/apprentice/checks/galera.rb', line 40 def check_ready_state return true if @status['wsrep_ready'] == 'ON' false end |
#get_galera_status ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/apprentice/checks/galera.rb', line 2 def get_galera_status begin result = @client.query "SHOW STATUS LIKE 'wsrep_%';" if result.count > 0 result.each do |r| @status.merge!(Hash[*r]) end end rescue Exception => puts end end |
#run_checks ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/apprentice/checks/galera.rb', line 15 def run_checks get_galera_status unless @status.empty? response = {code: 200, text: []} if !check_cluster_size response[:text] << "Cluster size is #{@status['wsrep_cluster_size']}. Split-brain situation is likely." end if !check_ready_state response[:text] << 'Cluster replication is not running.' end if !check_local_state response[:text] << "Local state is '#{STATES[@status['wsrep_local_state']]}'." end response[:code] = 503 unless response[:text].empty? return response else return {code: 503, text: ['Unable to determine cluster status']} end end |