Skip to content

Commit

Permalink
[BUG] mandatory warning or critical does not work
Browse files Browse the repository at this point in the history
  • Loading branch information
dbroeglin committed Jul 3, 2012
1 parent 136f050 commit 055e223
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/nagios_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def store_message(message)

def finish
value = @values.first.last
if @critical_range && !@critical_range.include?(value)
if @options.c && !@options.c.include?(value)
return [2, "CRITICAL"]
end
if @warning_range && !@warning_range.include?(value)
if @options.w && !@options.w.include?(value)
return [1, "WARNING"]
end
return [0, "OK"]
Expand Down Expand Up @@ -82,19 +82,19 @@ def defaults

def enable_warning(*args)
on("-w RANGE", *args) do |value|
@warning_range = NagiosCheck::Range.new(value)
self.options.w = NagiosCheck::Range.new(value)
end
end

def enable_critical(*args)
on("-c RANGE", *args) do |value|
@critical_range = NagiosCheck::Range.new(value)
self.options.c = NagiosCheck::Range.new(value)
end
end

def enable_timeout(*args)
on("-t TIMEOUT", *args) do |value|
@timeout = value.to_f
self.options.t = value.to_f
end
end

Expand Down Expand Up @@ -159,7 +159,7 @@ def parse_options(argv = ARGV)


def check_with_timeout
Timeout.timeout(@timeout) { check }
Timeout.timeout(@options.t) { check }
end

class MissingOption < StandardError;
Expand Down

0 comments on commit 055e223

Please sign in to comment.