class AwsInventory::Cloudwatch

Public Instance Methods

alarms() click to toggle source
# File lib/aws_inventory/cloudwatch.rb, line 35
def alarms
  @alarms ||= cw.describe_alarms.metric_alarms
end
compare_map() click to toggle source
# File lib/aws_inventory/cloudwatch.rb, line 26
def compare_map
  {
    "GreaterThanOrEqualToThreshold" => ">=",
    "GreaterThanThreshold" => ">",
    "LessThanOrEqualToThreshold" => "<=",
    "LessThanThreshold" => "<",
  }
end
data() click to toggle source
# File lib/aws_inventory/cloudwatch.rb, line 10
def data
  alarms.map do |alarm|
    [
      alarm.alarm_name,
      threshold_desc(alarm)
    ]
  end
end
header() click to toggle source
# File lib/aws_inventory/cloudwatch.rb, line 6
def header
  ["Alarm Name", "Threshold"]
end
threshold_desc(alarm) click to toggle source
# File lib/aws_inventory/cloudwatch.rb, line 19
def threshold_desc(alarm)
  a = alarm
  total_period = a.period * a.evaluation_periods
  time_in_words = distance_of_time_in_words(total_period)
  "#{a.metric_name} #{compare_map[a.comparison_operator]} #{a.threshold} for #{a.evaluation_periods} datapoints within #{time_in_words}"
end