Date post: | 15-Jan-2015 |
Category: |
Technology |
Upload: | ken-robertson |
View: | 3,213 times |
Download: | 4 times |
MonitoringA boring topic to most
Me
Ken Robertson
@krobertson
Demandbase
SF
Hiring! (HR made me do it)
DevOpsSexy Server Talk
Y U NO LIKE?
Metis
MetisImplements the Nagios NRPE protocol
Ruby daemon
Leverage gems
Simple framework for common stuff
Will add support for test helpers
define :eod do execute do
if Time.now.hour >= 23 critical("Real close now!") elsif Time.now.hour >= 21 warn("Getting close to the end of the day") else ok("We're all good")end
endend
define :eod do execute do
if Time.now.hour >= 23 critical("Real close now!") elsif Time.now.hour >= 21 warn("Getting close to the end of the day") else ok("We're all good")end
endend
define :eod do attribute :warning, :default => 21 attribute :critical, :default => 23 execute do
if Time.now.hour >= params[:critical] critical("Real close now!") elsif Time.now.hour >= params[:warning] warn("Getting close to the end of the day") else ok("We're all good")end
endend
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("We're behind a lot!") if seconds >= params[:critical] warn("We're behind some") if seconds >= params[:warning] ok endend
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("We're behind a lot!") if seconds >= params[:critical] warn("We're behind some") if seconds >= params[:warning] ok endend
describe :check_mysql_seconds_behind_master do include Metis::TestHelpers
it 'should return critical when very far behind' do mysql_result = double('result') mysql_result.stub(:fetch_hash).and_return({'Seconds_Behind_Master' => '120'}) Mysql.any_instance.stub(:query).and_return(mysql_result)
result = run_monitor(:check_mysql_seconds_behind_master) result.status.should == :critical result.message.should == "We're behind a lot!" endend
* This isn’t actually implemented yet, but will soon!
Metishttp://github.com/krobertson/metis
gem install metis
photo credit: http://www.flickr.com/photos/mafleen/3295163029/