bin/check-dynamodb-capacity.rb in sensu-plugins-aws-10.1.1 vs bin/check-dynamodb-capacity.rb in sensu-plugins-aws-10.1.2

- old
+ new

@@ -82,15 +82,15 @@ description: 'CloudWatch statistics method' option :capacity_for, short: '-c N', long: '--capacity-for NAME', - default: [:read, :write], + default: %i[read write], proc: proc { |a| a.split(/[,;]\s*/).map { |n| n.downcase.intern } }, description: 'Read/Write (or both) capacity to check.' - %w(warning critical).each do |severity| + %w[warning critical].each do |severity| option :"#{severity}_over", long: "--#{severity}-over N", # #YELLOW proc: proc(&:to_f), description: "Trigger a #{severity} if consumed capacity is over a percentage" @@ -154,15 +154,15 @@ config[:capacity_for].each do |r_or_w| metric_name = "Consumed#{r_or_w.to_s.capitalize}CapacityUnits" metric = cloud_watch_metric metric_name, table.table_name metric_value = begin latest_value(metric) - rescue + rescue StandardError 0 end percentage = metric_value / table.provisioned_throughput.send("#{r_or_w}_capacity_units").to_f * 100 - @severities.keys.each do |severity| + @severities.each_key do |severity| threshold = config[:"#{severity}_over"] next unless threshold next if percentage < threshold flag_alert severity, "; On table #{table.table_name} consumed #{r_or_w} capacity is #{sprintf '%.2f', percentage}% (expected_lower_than #{threshold})" break