Created
August 31, 2011 18:50
-
-
Save krobertson/1184363 to your computer and use it in GitHub Desktop.
Revisions
-
krobertson revised this gist
Aug 31, 2011 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,9 @@ # The definition... define :check_mysql_seconds_behind_master do 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' @@ -13,8 +14,8 @@ result.free connection.close critical("We're behind a lot!") if seconds >= critical warn("We're behind some") if seconds >= warning ok end end -
krobertson created this gist
Aug 31, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ # The definition... define :check_mysql_seconds_behind_master do 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(host[:ipaddress], username, password) result = connection.query('show slave status') seconds = result.fetch_hash['Seconds_Behind_Master'] result.free connection.close critical("We're behind a lot!") if seconds >= warning warn("We're behind some") if seconds >= critical ok end end # In the config file, the parameters need to be set. No passing over the network. # idea for method one check_mysql_seconds_behind_master do username "foo" password "bar" warning nil critical 10 end # idea for method two configure :check_mysql_seconds_behind_master do username "foo" password "bar" warning nil critical 10 end