Class: CfnGuardian::Resource::Nrpe

Inherits:
Base
  • Object
show all
Defined in:
lib/cfnguardian/resources/nrpe.rb

Instance Method Summary collapse

Methods inherited from Base

#default_event_subscriptions, #default_metric_filters, #get_alarms, #get_checks, #get_cost, #get_event_subscriptions, #get_events, #get_metric_filters, #resource_exists?

Methods included from Logging

colors, included, logger, #logger, logger=

Constructor Details

#initialize(resource, override_group = nil) ⇒ Nrpe

Returns a new instance of Nrpe.



7
8
9
10
11
# File 'lib/cfnguardian/resources/nrpe.rb', line 7

def initialize(resource, override_group = nil)
  super(resource, override_group)
  @resource_list = resource['Hosts']
  @environment = resource['Environment']
end

Instance Method Details

#default_alarmsObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/cfnguardian/resources/nrpe.rb', line 13

def default_alarms()
  @resource_list.each do |host|
    host['Commands'].each do |command|
      alarm = CfnGuardian::Models::NrpeAlarm.new(host,@environment)
      alarm.name = "#{command.to_camelcase}Warning"
      alarm.metric_name = command
      alarm.threshold = 0
      alarm.alarm_action = 'Warning'
      @alarms.push(alarm)
      
      alarm = CfnGuardian::Models::NrpeAlarm.new(host,@environment)
      alarm.name = "#{command.to_camelcase}Critical"
      alarm.metric_name = command
      alarm.threshold = 1
      alarm.alarm_action = 'Critical'
      @alarms.push(alarm)
    end
  end
end

#default_checksObject



41
42
43
# File 'lib/cfnguardian/resources/nrpe.rb', line 41

def default_checks()
  @checks.push(CfnGuardian::Models::NrpeCheck.new(@resource))
end

#default_eventsObject



33
34
35
36
37
38
39
# File 'lib/cfnguardian/resources/nrpe.rb', line 33

def default_events()
  @resource_list.each do |host|
    host['Commands'].each do |command|
      @events.push(CfnGuardian::Models::NrpeEvent.new(host,@environment,command))
    end
  end
end