nagios-zfs 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,4 +2,4 @@
2
2
 
3
3
  require 'nagios/zfs'
4
4
 
5
- Nagios::ZFS::ZpoolPlugin.new.check!
5
+ Nagios::ZFS::ZpoolPlugin.check
@@ -19,6 +19,10 @@ Feature: Check zpool capacity
19
19
  When I run `check_zpool -p tank -w 81 -c 82`
20
20
  Then the status should be ok
21
21
 
22
+ Scenario: Display actual capacity
23
+ When I run `check_zpool -p tank -w 79 -c 80`
24
+ Then the stdout should contain "tank 80%"
25
+
22
26
  #NOTE: This currently does not work!
23
27
  #Scenario: Unknown zpool name
24
28
  #When I run `check_zpool -p foo -w 81 -c 82`
@@ -1,5 +1,5 @@
1
1
  module Nagios
2
2
  module ZFS
3
- VERSION = '0.0.1'
3
+ VERSION = '0.1.0'
4
4
  end
5
5
  end
@@ -1,7 +1,10 @@
1
1
  module Nagios
2
2
  module ZFS
3
3
  class Zpool
4
+ attr_reader :name
5
+
4
6
  def initialize(name)
7
+ raise 'missing pool name' if [nil, ''].include?(name)
5
8
  @name = name
6
9
  end
7
10
 
@@ -9,7 +9,7 @@ module Nagios
9
9
 
10
10
  option :critical,
11
11
  :short => '-c CRITICAL_CAPACITY',
12
- :short => '--critical CRITICAL_CAPACITY',
12
+ :long => '--critical CRITICAL_CAPACITY',
13
13
  :proc => Proc.new { |config| config.to_i }
14
14
 
15
15
  option :warning,
@@ -35,6 +35,10 @@ module Nagios
35
35
  true
36
36
  end
37
37
 
38
+ def message
39
+ "#{zpool.name} #{zpool.capacity}%"
40
+ end
41
+
38
42
  private
39
43
 
40
44
  def critical_capacity?
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'nagiosplugin', '~> 2.0'
21
+ spec.add_dependency 'nagiosplugin', '~> 2.1'
22
22
  spec.add_dependency 'mixlib-cli', '~> 1.3'
23
23
 
24
24
  spec.add_development_dependency 'bundler', '~> 1.3'
@@ -78,6 +78,16 @@ module Nagios
78
78
  end
79
79
  end
80
80
 
81
+ describe '#message' do
82
+ it 'includes the pool name and capcity' do
83
+ zpool = double('zpool')
84
+ zpool.should_receive(:name).and_return('tank')
85
+ zpool.should_receive(:capacity).and_return(42)
86
+ plugin.stub(:zpool).and_return(zpool)
87
+ expect(plugin.message).to eq('tank 42%')
88
+ end
89
+ end
90
+
81
91
  describe '#zpool' do
82
92
  let(:zpool) { double('zpool') }
83
93
 
@@ -9,6 +9,18 @@ module Nagios
9
9
  Zpool.any_instance.stub(:`).and_return('')
10
10
  end
11
11
 
12
+ it 'raises an error on empty pool name' do
13
+ [nil, ''].each do |name|
14
+ expect { Zpool.new(name) }.to raise_error /missing pool name/
15
+ end
16
+ end
17
+
18
+ describe '#name' do
19
+ it 'returns the pool name' do
20
+ expect(zpool.name).to eq('tank')
21
+ end
22
+ end
23
+
12
24
  describe '#capacity' do
13
25
  it 'returns the capacity' do
14
26
  zpool.should_receive(:query).and_return("tank\t87%\n")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nagios-zfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '2.0'
21
+ version: '2.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: '2.0'
29
+ version: '2.1'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: mixlib-cli
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -182,7 +182,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
182
182
  version: '0'
183
183
  segments:
184
184
  - 0
185
- hash: -4547917835531828401
185
+ hash: 4578558176594243719
186
186
  required_rubygems_version: !ruby/object:Gem::Requirement
187
187
  none: false
188
188
  requirements:
@@ -191,13 +191,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  version: '0'
192
192
  segments:
193
193
  - 0
194
- hash: -4547917835531828401
194
+ hash: 4578558176594243719
195
195
  requirements: []
196
196
  rubyforge_project:
197
197
  rubygems_version: 1.8.23
198
198
  signing_key:
199
199
  specification_version: 3
200
- summary: nagios-zfs-0.0.1
200
+ summary: nagios-zfs-0.1.0
201
201
  test_files:
202
202
  - features/check_zpool_capacity.feature
203
203
  - features/step_definitions/dev_steps.rb