Method: Nines::CheckGroup#initialize
- Defined in:
- lib/nines/check_group.rb
#initialize(options = {}) ⇒ CheckGroup
Returns a new instance of CheckGroup.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/nines/check_group.rb', line 5 def initialize( = {}) .stringify_keys! @name = ['name'] @description = ['description'] parameters = ['parameters'] || {} parameters.stringify_keys! @check_type = parameters.delete('type') @contacts = [] notify = ['notify'] || [] notify.each do |contact| contact.stringify_keys! @contacts << { 'name' => contact['contact'], 'after' => contact['after'] || 2, 'every' => contact['every'] || 5, 'upto' => contact['upto'] || 5 } end @checks = [] checks = ['checks'] || [] checks.each do |check| check = { hostname: check } unless check.is_a?(Hash) check.stringify_keys! case @check_type when 'http' @checks << HttpCheck.new(self, parameters.merge(check)) when 'ping' @checks << PingCheck.new(self, parameters.merge(check)) else raise Exception.new("Unknown check type: #{@check_type} (supported values: http, ping)") end end end |