Skip to content

Instantly share code, notes, and snippets.

Avatar
:electron:
Kubernetes Early Adopter (2016)

Stephan Kristyn stevek-pro

:electron:
Kubernetes Early Adopter (2016)
  • Site Reliability Engineer für testgetriebene Software Entwicklung, Automation, ML Pipelines, zeroOps
  • München, Bayern
  • Twitter @transformatik
View GitHub Profile
@stevek-pro
stevek-pro / check_slave_status.rb
Created Feb 2, 2016 — forked from blasterpal/check_slave_status.rb
Check MySQL Slave status from Shell using Ruby
View check_slave_status.rb
#!/usr/bin/env ruby
@slave_status = Hash[%x(mysql -uroot -e 'SHOW SLAVE STATUS \\\G').split(/\s*\n\s*/).map { |e| spl = e.split(/\:\s*/); spl.size == 2 ? [spl.first, spl.last] : nil }.compact]
def slave_healthy?
@slave_status['Slave_IO_Running'] == 'Yes' &&
@slave_status['Slave_SQL_Running'] == 'Yes' &&
@slave_status['Seconds_Behind_Master'] != 'NULL' &&
@slave_status['Seconds_Behind_Master'].to_i < 1800
end