# 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