Created
August 31, 2011 18:50
-
-
Save krobertson/1184363 to your computer and use it in GitHub Desktop.
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 characters
# 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 >= critical | |
warn("We're behind some") if seconds >= warning | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment