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.
- data/lib/aws-reporting/alarm.rb +15 -2
- data/lib/aws-reporting/version.rb +1 -1
- metadata +1 -1
data/lib/aws-reporting/alarm.rb
CHANGED
@@ -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
|
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
|