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

Threshold specification fixes #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

edlitmus
Copy link

@edlitmus edlitmus commented Apr 18, 2017

After writing tests for a monitoring tool that uses this module I notices what seems like deviations from the written specs for thresholds, going by:

https://nagios-plugins.org/doc/guidelines.html#THRESHOLDFORMAT

For instance, this rule:

@6

by my reading should mean 'inside the range [0 - 6]', while this rule:

6

would be 'anything outside the range [6 - positive infinity]', so anything less than 6.

Similarly, ~:25 would be anything over 25, while @~:25 would be 'anything in the range of negative infinity to 25'.

If I'm on crack please feel free to say so.

@hirotnk
Copy link

hirotnk commented Apr 18, 2017

The link to the nagios document is broken ?

@edlitmus
Copy link
Author

fixed link in description

@sni
Copy link
Contributor

sni commented Apr 20, 2017

Mixing whitespace changes with functional changes makes reviews really hard. I also don't understand whats the purpose of invertig the unit tests?

};
test_expected( $r, $expected );

diag "range 10..infinity , inclusive" if $ENV{TEST_VERBOSE};
test_expected( $r, $expected );
$r = Monitoring::Plugin::Range->parse_range_string("10:");
$r = Monitoring::Plugin::Range->parse_range_string("\@10:");
use Data::Dumper::Concise;
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to leftover debug code.

my $r = shift;
my $expected = shift;
foreach ( sort { $a <=> $b } keys %$expected ) {
my $res = $r->check_range($_);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not used at all.

@edlitmus
Copy link
Author

Here are some notes:

  • parse_range_string() was not setting $range->end_infinity(0); in the last if statement

  • The test diag statements specified that they were inclusive tests, but according to the spec they were testing exclusion.

  • check_range() was not applying the rules for inclusion/exclusion of ranges according to the spec and didn't untainted the $value variable passed in.

Sorry about the white space thing. There was a mix of tabs and spaces that made parts hard to read and I ran them through perltidy out of habit.

@dermoth
Copy link
Member

dermoth commented Apr 26, 2017

About whitespace, IIRC we settled toward using tabs for indent and space for alignment (i.e. continuation lines should be tab-indented like the preceding line then space-indented to align). ex:

sub main {
[TAB]if ($foo & 0x0010 &&
[TAB][SP]$bar & 0x1000) {
[TAB][TAB]do_something();
[TAB]}
}

This way you can adjust the tab size to your liking and alignment remains correct.

I believe only 7 lines would be affected if you fix indents accordingly.

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants