9. Metis
Implements the Nagios NRPE protocol
Ruby daemon
Leverage gems
Simple framework for common stuff
Will add support for test helpers
10. 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
end
end
11. 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
end
end
12. 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
end
end
13. 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
end
end
14. 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
end
end
15. 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!"
end
end
* This isn’t actually implemented yet, but will soon!