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

Update check-elb-sum-requests.rb to AWS SDK v2 #297

Merged
merged 6 commits into from
Nov 2, 2018

Conversation

boutetnico
Copy link
Contributor

@boutetnico boutetnico commented Oct 24, 2018

Disclosure: I'm not a Ruby programmer, I cannot run the test suite, please review my changes.

Pull Request Checklist

Issue related: #240

General

  • Update Changelog following the conventions laid out here

  • Update README with any necessary configuration snippets

  • Binstubs are created if needed

  • RuboCop passes

  • Existing tests pass

Purpose

Update to AWS SDK v2.

Known Compatibility Issues

This is a breaking change because it removes aws_access_key and aws_secret_access_key options per #2.

Examples

Before this PR

Check all ELB in a region having 1 LB

$ ./check-elb-sum-requests.rb -a <key> -k <secret> -r eu-west-1
264.0
264.0
CheckELBSumRequests OK: <AWS::ELB::LoadBalancer name:my_lb>; ( within 60 seconds between 2018-10-28 07:55:37 +0000 to 2018-10-28 07:56:37 +0000)

Check all ELB in a region having 1 LB with a warning status

$ ./check-elb-sum-requests.rb -a <key> -k <secret> -r eu-west-1 --warning-over 10
351.0
351.0
CheckELBSumRequests WARNING: <AWS::ELB::LoadBalancer name:my_lb>;  Sum Requests is 351.0. (expected lower than 10.0); ( within 60 seconds between 2018-10-28 07:59:22 +0000 to 2018-10-28 08:00:22 +0000)

Check all ELB in a region having 2 LB

$ ./check-elb-sum-requests.rb -a <key> -k <secret> -r eu-west-1
126.0
126.0
0
0
CheckELBSumRequests OK: 2 load balancers total; ( within 60 seconds between 2018-10-28 08:50:16 +0000 to 2018-10-28 08:51:16 +0000)

Check all ELB in a region having 2 LB with a warning status

$ ./check-elb-sum-requests.rb -a <key> -k <secret> -r eu-west-1 --warning-over 10
206.0
206.0
0
0
CheckELBSumRequests WARNING: 2 load balancers total; <AWS::ELB::LoadBalancer name:my_lb>'s Sum Requests is 206.0. (expected lower than 10.0); ( within 60 seconds between 2018-10-28 08:51:07 +0000 to 2018-10-28 08:52:07 +0000)

After this PR

Check all ELB in a region having 1 LB

$ ./check-elb-sum-requests.rb -r eu-west-1
CheckELBSumRequests OK: my_lb; (Sum within 60 seconds between 2018-10-28 08:15:58 UTC to 2018-10-28 08:16:58 UTC)

Check all ELB in a region having 1 LB with a warning status

$ ./check-elb-sum-requests.rb -r eu-west-1 --warning-over 10
CheckELBSumRequests WARNING: my_lb;  Sum Requests is 215.0. (expected lower than 10.0); (Sum within 60 seconds between 2018-10-28 08:16:11 UTC to 2018-10-28 08:17:11 UTC)

Check all ELB in a region having 2 LB

$ ./check-elb-sum-requests.rb -r eu-west-1
CheckELBSumRequests OK: 2 load balancers total; (Sum within 60 seconds between 2018-10-28 08:58:10 UTC to 2018-10-28 08:59:10 UTC)

Check all ELB in a region having 2 LB with a warning status

$ ./check-elb-sum-requests.rb -r eu-west-1 --warning-over 10
CheckELBSumRequests WARNING: 2 load balancers total; my_lb's Sum Requests is 179.0. (expected lower than 10.0); (Sum within 60 seconds between 2018-10-28 08:59:55 UTC to 2018-10-28 09:00:55 UTC)

@majormoses
Copy link
Member

@boutetnico any chance you could show us the input and output before and after the change? Here is an example

I am gonna review shortly but showing that its still functional even if only manual increases the confidence of accepting changes.

Copy link
Member

@majormoses majormoses left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good, have a couple of questions and feedback. Keep up the good work your ruby skills seem just fine to me. I was also a sysadmin who learned to code.

CHANGELOG.md Outdated
@@ -4,6 +4,8 @@ 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]
### Breaking Changes
- `check-elb-sum-requests.rb` was updated to aws-sdk v2 and no longer take `aws_access_key` and `aws_secret_access_key` options. (@boutetnico)
Copy link
Member

@majormoses majormoses Oct 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd split these up into two entries but I can do that for you. Basically the removal of the CLI args are the breaking change aside from that upgrading to v2 should be backwards compatible and that should go under ### Changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

CHANGELOG.md Show resolved Hide resolved
@@ -132,7 +121,6 @@ def check_sum_requests(elb)

@severities.each_key do |severity|
threshold = config[:"#{severity}_over"]
puts metric_value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this being removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this because it looks like a debug statement that was left and forgot. See example output:

$ ./check-elb-sum-requests.rb -a <key> -k <secret> -r eu-west-1
264.0
264.0
CheckELBSumRequests OK: <AWS::ELB::LoadBalancer name:my_alb>; ( within 60 seconds between 2018-10-28 07:55:37 +0000 to 2018-10-28 07:56:37 +0000)

else
"#{elbs.size} load balancers total"
end
@message = "#{elbs.size} load balancers total"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are removing the check to be grammatically correct we should add a parenthesis around the plural form

balancer(s)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted, will change it, thanks.

@boutetnico
Copy link
Contributor Author

@majormoses thank you for your review, I have updated my PR according to your feedback. Please have a look at examples in my first post.

@majormoses majormoses merged commit b30618b into sensu-plugins:master Nov 2, 2018
@majormoses
Copy link
Member

released: https://rubygems.org/gems/sensu-plugins-aws/versions/14.0.0

I had to manually release because we have clogged up travis by enabling https://dependabot.com to help us with a lot of the maintenance work involved in keeping this project working so I can spend more time adding features and fixing bugs.

@boutetnico boutetnico deleted the elb_sum_requests branch May 7, 2019 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants