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

adding cert option to some checks and metrics #101

Merged
merged 5 commits into from
Feb 20, 2018

Conversation

csoleimani
Copy link
Contributor

@csoleimani csoleimani commented Nov 29, 2017

Pull Request Checklist

Is this in reference to an existing issue?
kind of. #100

it's better to pass in a cert than not check for validation

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

New Plugins

  • Tests

  • Add the plugin to the README

  • Does it have a complete header as outlined here

Purpose

Known Compatibility Issues

@majormoses
Copy link
Member

Let me know if you need help working through the rubocop errors.

@csoleimani
Copy link
Contributor Author

Sure, some help would be great. I tried running the autofix flag, but it just created some more issues. I'm not very familiar with Ruby and don't know all the best practices

@csoleimani csoleimani closed this Dec 26, 2017
@csoleimani csoleimani reopened this Dec 26, 2017
@majormoses
Copy link
Member

majormoses commented Dec 29, 2017

I went through the cops one by one, in some cases they were rather opinionated other places we should certainly refactor at a later date.

@majormoses
Copy link
Member

Thanks for your contribution to Sensu plugins! Without people like you submitting PRs we couldn't run the project. I will review it shortly.

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 great, there are a few things that can be improved as well as some missing bits.

Missing bits:

As per my comment here we should probably add some documentation about the dangers of providing secrets directly to the CLI.

@@ -36,4 +36,4 @@ task :check_binstubs do
end
end

task default: [:spec, :make_bin_executable, :yard, :rubocop, :check_binstubs]
task default: %i(spec make_bin_executable yard rubocop check_binstubs)
Copy link
Member

Choose a reason for hiding this comment

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

pretty sure this changes in a newer version of rubocop, but that change is I believe breaking so we can change that back when we update it.

# rubocop:disable LineLength
used_in_bytes = nodes_being_used.map { |node| node['fs']['data'].map { |data| data['total_in_bytes'] - data['available_in_bytes'] }.flatten }.flatten.inject { |sum, x| sum + x }
# rubocop:enable LineLength
# TODO: come back and cleanup all these rubocop disables with a little refactor
Copy link
Member

Choose a reason for hiding this comment

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

I know this is not the code that was changed but somehow rubocop started complaining. This is super ugly and hard to read, we should come back and refactor this later.

@majormoses
Copy link
Member

@csoleimani any chance on coming back to get this cleaned up and over the line?

Copy link

@thomasriley thomasriley left a comment

Choose a reason for hiding this comment

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

As requested by @majormoses I have just tested the --cert option against an Elasticsearch cluster that has HTTPS enabled and it works as expected.

[riley:...sensu-plugins-elasticsearch]$ bundle exec bin/check-es-cluster-status.rb --host elastic.example.com --port 9200 --https true --user 'admin' --password 'password' --cert ~/Downloads/Root.crt
ESClusterStatus OK: Cluster is green

@majormoses
Copy link
Member

@thomasriley thanks for testing I will review this tonight or tomorrow and hopefully merge and release this.

@majormoses
Copy link
Member

Looks like we need a rebase.

@majormoses
Copy link
Member

I rebased for you, sorry for the long delay.

@majormoses
Copy link
Member

To avoid confusion I am gonna rename the option from --cert to --cert-file to make it clear that this supports passing a file name not the actual cert directly via cli.

@majormoses
Copy link
Member

majormoses commented Feb 19, 2018

Hmm one more thought is that -c is usually used to specify a critical threshold. I checked and none of the checks that this was added to need that but there are others such as this one that do in this repo. I think we should remove the short option to keep it consistent.

@thomasriley
Copy link

@majormoses I agree on both using the --cert-file name to ensure that option is descriptive and avoid using the short -c to avoid confusion and maintain consistency.

…itical thresholds in other checks in this repo as well as that being a standard across plugins.
@majormoses majormoses merged commit 8243eab into sensu-plugins:master Feb 20, 2018
majormoses added a commit that referenced this pull request Feb 20, 2018
@majormoses
Copy link
Member

@wtibbitts
Copy link

Why was this not added to all checks?

@majormoses
Copy link
Member

@jwsomis cant say but you are welcome to open up a PR for any missing ones.

@csoleimani
Copy link
Contributor Author

I think I had some problems with the ones I didn't add it to, but it was so long ago that I don't remember what they are. Feel free to give it a shot, though!

@wtibbitts
Copy link

wtibbitts commented Dec 5, 2019 via email

@csoleimani
Copy link
Contributor Author

This is the best guide I have seen around sharing assets:

https://discourse.sensu.io/t/contributing-assets-for-existing-ruby-sensu-plugins/1165

@wtibbitts
Copy link

wtibbitts commented Dec 5, 2019 via email

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.

5 participants