bin/check-sqs-messages.rb in sensu-plugins-aws-18.5.0 vs bin/check-sqs-messages.rb in sensu-plugins-aws-18.6.0
- old
+ new
@@ -116,10 +116,19 @@
crits = []
passing = []
queues = config[:queues]
queues.each do |q|
url = sqs.get_queue_by_name(queue_name: q).url
- messages = sqs.client.get_queue_attributes(queue_url: url, attribute_names: ['All']).attributes[config[:metric]].to_i
+ messages = sqs.client.get_queue_attributes(queue_url: url, attribute_names: ['All'])
+ if messages.attributes.key(config[:metric])
+ messages = messages.attributes([config[:metric]]).to_i
+ else
+ failure_msg = <<~MESSAGE
+ failed to pull metric #{config[:metric]} on queue: #{q}.
+ available attributes: #{messages.attributes}
+ MESSAGE
+ unknown failure_msg
+ end
if (config[:crit_under] >= 0 && messages < config[:crit_under]) || (config[:crit_over] >= 0 && messages > config[:crit_over])
crits << "#{messages} message(s) in #{q}"
elsif (config[:warn_under] >= 0 && messages < config[:warn_under]) || (config[:warn_over] >= 0 && messages > config[:warn_over])
warnings << "#{messages} message(s) in #{q}"