aws-reporting 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,9 +13,22 @@ module AwsReporting
13
13
  :status => get_status(alarm)}
14
14
  end
15
15
 
16
+ def alarmed?(history)
17
+ return false unless history.history_item_type == 'StateUpdate'
18
+
19
+ data = JSON.parse(history.history_data)
20
+ if data["oldState"]["stateValue"] == 'INSUFFICIENT_DATA' and data["newState"]["stateValue"] == 'OK'
21
+ false
22
+ elsif data["oldState"]["stateValue"] == 'OK' and data["newState"]["stateValue"] == 'INSUFFICIENT_DATA'
23
+ false
24
+ else
25
+ true
26
+ end
27
+ end
28
+
16
29
  def get_status(alarm)
17
30
  return :ALARM if alarm.state_value == 'ALARM'
18
- return :ALARM if alarm.history_items.to_a.select{|history| history.history_item_type == 'StateUpdate'}.length > 0
31
+ return :ALARM if alarm.history_items.to_a.select{|history| alarmed?(history)}.length > 0
19
32
  return :OK
20
33
  end
21
34
 
@@ -31,6 +44,6 @@ module AwsReporting
31
44
  alarms.sort_by{|alarm| [alarm[:namespace], serialize(alarm[:dimensions]), alarm[:metric_name], alarm[:name]].join(' ')}
32
45
  end
33
46
 
34
- module_function :get_alarms
47
+ module_function :get_alarms, :get_alarm_info, :get_status, :serialize, :alarmed?
35
48
  end
36
49
  end
@@ -1,7 +1,7 @@
1
1
  module AwsReporting
2
2
  module Version
3
3
  def get
4
- "AWS-Reporting v0.9.1"
4
+ "AWS-Reporting v0.9.2"
5
5
  end
6
6
 
7
7
  module_function :get
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-reporting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: