Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

define :check_mysql_seconds_behind_master do attribute :host, Metis - RubyConf 2011 Lightning Talk

3,612 views

Published on

define :check_mysql_seconds_behind_master do attribute :host, :kind_of => String, :default => ‘127.0.0.1’ attribute :username, :kind_of => String attribute :password, :kind_of => String attribute :warning, :kind_of => Fixnum, :default => 20 attribute :critical, :kind_of => Fixnum, :default => 60 require_gem mysql execute do connection = Mysql.new(params[:host], params[:username], params[:password]) result = connection.query(show slave status) seconds = result.fetch_hash[Seconds_Behind_Master].to_i result.free connection.close critical("Were behind a lot!") if seconds >= params[:critical] warn("Were behind some") if seconds >= params[:warning] ok endend

Published in: Technology
  • Be the first to comment

  • Be the first to like this

×