nagios_check 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module NagiosCheck
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/nagios_check.rb CHANGED
@@ -50,10 +50,10 @@ module NagiosCheck
50
50
 
51
51
  def finish
52
52
  value = @values.first.last
53
- if @critical_range && !@critical_range.include?(value)
53
+ if @options.c && !@options.c.include?(value)
54
54
  return [2, "CRITICAL"]
55
55
  end
56
- if @warning_range && !@warning_range.include?(value)
56
+ if @options.w && !@options.w.include?(value)
57
57
  return [1, "WARNING"]
58
58
  end
59
59
  return [0, "OK"]
@@ -67,7 +67,7 @@ module NagiosCheck
67
67
  def on(*args, &block)
68
68
  name = option_name(args.first)
69
69
  option_params = {
70
- mandatory: args.delete(:mandatory) ? true : false
70
+ :mandatory => args.delete(:mandatory) ? true : false
71
71
  }
72
72
  if args.last.respond_to? :has_key?
73
73
  option_params.merge! args.pop
@@ -78,26 +78,26 @@ module NagiosCheck
78
78
 
79
79
  def defaults
80
80
  @defaults
81
- end
81
+ end
82
82
 
83
83
  def enable_warning(*args)
84
84
  on("-w RANGE", *args) do |value|
85
- @warning_range = NagiosCheck::Range.new(value)
85
+ self.options.w = NagiosCheck::Range.new(value)
86
86
  end
87
87
  end
88
88
 
89
89
  def enable_critical(*args)
90
90
  on("-c RANGE", *args) do |value|
91
- @critical_range = NagiosCheck::Range.new(value)
91
+ self.options.c = NagiosCheck::Range.new(value)
92
92
  end
93
93
  end
94
-
94
+
95
95
  def enable_timeout(*args)
96
96
  on("-t TIMEOUT", *args) do |value|
97
- @timeout = value.to_f
97
+ self.options.t = value.to_f
98
98
  end
99
99
  end
100
-
100
+
101
101
  def check_options!(options)
102
102
  @option_specs.each do |name, spec|
103
103
  _, option_params, _ = spec
@@ -159,7 +159,7 @@ module NagiosCheck
159
159
 
160
160
 
161
161
  def check_with_timeout
162
- Timeout.timeout(@timeout) { check }
162
+ Timeout.timeout(@options.t) { check }
163
163
  end
164
164
 
165
165
  class MissingOption < StandardError;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nagios_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-21 00:00:00.000000000Z
12
+ date: 2012-07-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  version: '0'
85
85
  requirements: []
86
86
  rubyforge_project: nagios_check
87
- rubygems_version: 1.8.19
87
+ rubygems_version: 1.8.24
88
88
  signing_key:
89
89
  specification_version: 3
90
90
  summary: Ruby Nagios Check Integration