Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight false positives in check-sqs-messages when metric is unsupported #381

Merged
merged 3 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@

AllCops:
TargetRubyVersion: 2.3
MethodLength:
Max: 200
Max: 200

LineLength:
Max: 225
Max: 225

AbcSize:
Max: 125

FileName:
Enabled: false
Enabled: false

PerceivedComplexity:
Enabled: false
Enabled: false

CyclomaticComplexity:
Enabled: false
Enabled: false

ClassLength:
Enabled: false
Enabled: false

IfUnlessModifier:
Enabled: false
Enabled: false

RegexpLiteral:
Enabled: false
Expand All @@ -38,6 +39,13 @@ Style/FormatString:
Style/FrozenStringLiteralComment:
Enabled: false

Style/NumericPredicate:
Enabled: false

# I think we probably want to change this at some point
Style/SafeNavigation:
Enabled: false

Style/ClassVars:
Exclude:
- test/**/*.rb
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)

## [Unreleased]

### Fixed
- `check-sqs-messages.rb`: properly surface false positives when pulling an unsupported metric (@majormoses)

## [18.5.0] - 2020-01-28
### Changed
- `check-trustedadvisor-service-limits.rb`: Trusted Advisor combined Service Limits check ID 'eW7HH0l7J9' scheduled to be disabled on Feb 15 2020. Updated the script to go through every Service Limits checks and look for not 'ok' status. Outcome is the same. (@swibowo)
Expand Down
11 changes: 10 additions & 1 deletion bin/check-sqs-messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,16 @@ def run
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}"
Expand Down