-
Notifications
You must be signed in to change notification settings - Fork 55
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
Added -R
to check-process.rb for RSS checks
#46
Conversation
Also includes some minor rubocop fixes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good just some minor tweaks and some clarification
CHANGELOG.md
Outdated
@@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). | |||
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/) | |||
|
|||
## [Unreleased] | |||
## Changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Added
as this is new functionality not changing existing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected
bin/check-process.rb
Outdated
@@ -287,7 +300,7 @@ def run | |||
|
|||
if config[:metric] | |||
# #YELLOW | |||
count = procs.map { |p| p[config[:metric]].to_i }.reduce { |a, b| a + b } # rubocop:disable SingleLineBlockParams | |||
count = procs.map { |p| p[config[:metric]].to_i }.reduce { |a, e| a + e } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this change or why it would fix rubocop you just renamed the variables...can you expand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comes from Style/SingleLineBlockParams. Here are the tests rubocop runs for an example of what led to the message:
Name `reduce` block params `|a, e|`.
I'm perfectly happy to put things back how I found them, but I guessed that a previous committer may not have fully understood the SingleLineBlockParams cop and could have avoided the rubocop:disable
. Switching b
to e
makes everything happy.
Might have had something to do with my editor vs. running rubocop from the CLI, but I ran bundle exec rubocop
and needed to make this change for it to pass locally, though Atom was perfectly happy before I made the change.
Let me know how to proceed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a real change so unless someone can explain why one is good and the other is bad I am going to assume that this is a false positive, highly subjective / opinionated, or just a bad rule. I would prefer to ignore behavior rather than make a change without a reason. Would you be open to creating an issue on rubocop and feel free to tag me on this? If there is something that makes this special I would like to know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll undo this change in a commit in just a second.
For your reference, the docs for rubocop for this rule are here:
http://rubocop.readthedocs.io/en/latest/cops_style/#stylesinglelineblockparams
The relevant section is {"reduce"=>["acc", "elem"]}, {"inject"=>["acc", "elem"]}
.
I'm guessing acc
there is the "acculumator value (memo)" and elem
is for "element" from the Ruby Standard Library docs for Enumerable
. So shortening those names to a
and e
makes sense. Opinionated? Perhaps. But at least I can see where the logic comes from.
Either way, not trying to impose more rules than this repo's maintainers would care to adhere to, so I'll revert this change.
procs.select! { |p| p[:rss].to_f > config[:rss] } if config[:rss] | ||
# Ensure RSS is under this value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is wrong...swap it with the comment above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can clarify (or remove entirely) the comments I added there, but I'm not sure they are incorrect. Looking at both RSS-related selects:
# Ensure RSS is over this value
procs.select! { |p| p[:rss].to_f > config[:rss] } if config[:rss]
# Ensure RSS is under this value
procs.select! { |p| p[:over_rss].to_f < config[:over_rss] } if config[:over_rss]
The first (and original) selects only those processes (p
) whose reported RSS (:rss
) is greater than the supplied value in config
(thus my comment of # Ensure RSS is over this value
).
The second selects only those processes whose reported RSS is less than the supplied value in the config
(thus my comment of # Ensure RSS is under this value
). Albeit, the use of "under" and the config key of :over_rss
is not super clear, my intention on the new -R
is to alert when the RSS value goes over the value you specify on the command line, so I think it still fits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, my last comment made me see that the process (p
) key should be :rss
for that comparison. You'll see another commit in just a second.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that must have been what threw me off, makes perfect sense now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still looks wrong to me:
# Alert if RSS is over this value
+ option :over_rss,
+ # Ensure RSS is over this value
 procs.select! { |p| p[:rss].to_f > config[:rss] } if config[:rss]
+ # Ensure RSS is under this value
+ procs.select! { |p| p[:rss].to_f < config[:over_rss] } if config[:over_rss]
I would write it like this which makes more sense to me:
# Alert if RSS is under this value
+ option :rss_under,
# Alert if RSS is over this value
+ option :rss_over,
+ # Ensure RSS is over this value
 procs.select! { |p| p[:rss].to_f > config[:rss_over] } if config[:rss_over]
+ # Ensure RSS is under this value
+ procs.select! { |p| p[:rss].to_f < config[:rss_under] } if config[:rss_under]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if we should just always log a message saying something to this effect:
INFO: checking if there are (greater|less) than (warn|crit) thresholds
CheckProcess OK: Found 6 matching processes; cmd /google/; rss > 368381
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I am almost tempted to say there should be no defaults for any of the crit/warnings if we want to stay flexible and keep it all in the same check. Let the user tell us what they want to check as we cant have sane defaults for both scenarios as they are mutually exclusive from what I see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would obviously be a breaking change @eheydrick thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thankful that I'm not the only one that finds this check's options less than intuitive. I'm happy with postponing / canceling this PR until this discussion is concluded. I'll probably just write a really simple check to do just what I need for now. I'm also happy to help contribute to a library too if that would be valuable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can do what you need with the existing features as outlined above. you just need to set -w, -c
to what they should be. Let's close out this PR and continue the discussion in the issue. I really do want to improve this but what is proposed is already available so unless we make things more intuitive I don't see anything that should be addressed here.
This looks good now, I will take a second pass and hopefully do some testing and release tomorrow. |
closing per: #46 (comment) |
Added
-R
to check-process.rb to address #45.Also includes some minor rubocop fixes
Pull Request Checklist
Is this in reference to an existing issue?
Yes, #45.
General
Update Changelog following the conventions laid out on Keep A Changelog
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 Compatablity Issues