check_disk 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b755cacc90b2df969b93ee370d04da3bd23806b
4
- data.tar.gz: cf515342fb6a4cd7696feec1e4c4fed166775146
3
+ metadata.gz: cb363a728a29f9ad725dd1a6bf9d82b6f8a4d396
4
+ data.tar.gz: 3a6af8c3c9dfb5b0a654b5c022122043814ff651
5
5
  SHA512:
6
- metadata.gz: 71556149db3ca216e8906077dfe7bac59dd9ac29b94629482e3a73031a3592ee375781d58e4edb87183224920047062e64e5af91b649dce35bf9fddd4f621243
7
- data.tar.gz: 12d75b592527d1e9c6773fab67589563d8d04f3658461960b2757ef335418a7514d596c6508e3e3769f5da88e3d00f459bf550fa09c721008c09638a98da4fe5
6
+ metadata.gz: 0293897ed89e0667f7de913966482802b6518d01641023d9ce130a491a0a0fd9905f32b9a11b8edbf6e7b8179cb0dab7916960eae89cc13aba0077ac7a85be45
7
+ data.tar.gz: f6f75a57d61a9f0e9551c9baa7ec5488658cb5570bb903a801545f28e479a0bf0e694b2c942bdaa26f24cea178686e6c2bcf5e8925327b3ec62913d44844e84f
checksums.yaml.gz.sig CHANGED
Binary file
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ cache:
3
+ - bundler
4
+ rvm:
5
+ - 2.1.2
6
+ gemfile: Gemfile
7
+ script: bundle exec rake test:minitest
data/bin/check_disk.rb CHANGED
@@ -25,9 +25,27 @@ module CheckDisk
25
25
 
26
26
  # Sensu check run loop.
27
27
  def run
28
- check_blocks if config[:blocks]
29
- check_inodes if config[:inodes]
30
- ok 'You need to pass either `-i` or `-b`.'
28
+ blocks if config[:blocks]
29
+ inodes if config[:inodes]
30
+ check_blocks_and_inodes
31
+ end
32
+
33
+ private
34
+
35
+ def blocks
36
+ check_blocks
37
+ ok
38
+ end
39
+
40
+ def inodes
41
+ check_inodes
42
+ ok
43
+ end
44
+
45
+ def check_blocks_and_inodes
46
+ check_blocks
47
+ check_inodes
48
+ ok 'block and inode usage lower than warning threshold.'
31
49
  end
32
50
 
33
51
  def check_blocks
@@ -44,11 +62,8 @@ module CheckDisk
44
62
  message(disk.message)
45
63
  warning if disk.warning?
46
64
  critical if disk.critical?
47
- ok
48
65
  end
49
66
 
50
- private
51
-
52
67
  # Adds a `-p` or `--path` option to our CLI.
53
68
  # Sets `config[:path]`
54
69
  # @return [String] The `path` or `mount point` we are checking.
data/check_disk.gemspec CHANGED
@@ -15,9 +15,10 @@ Gem::Specification.new do |spec|
15
15
  spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) }
16
16
  spec.test_files = spec.files.grep(/^(test|spec|features)/)
17
17
  spec.require_paths = %w(lib)
18
- spec.cert_chain = ['certs/miah_johnson.pem']
19
- spec.signing_key = '/Users/miah/.gem_certs/gem-private_key.pem'
20
-
18
+ unless ENV['CI'].eql?('true') || ENV['CONTINUOUS_INTEGRATION'].eql?('true')
19
+ spec.cert_chain = ['certs/miah_johnson.pem']
20
+ spec.signing_key = '/Users/miah/.gem_certs/gem-private_key.pem'
21
+ end
21
22
  spec.add_runtime_dependency 'sensu-plugin', '~> 0.3', '>= 0.3.0'
22
23
  spec.add_runtime_dependency 'sys-filesystem', '~> 1.1', '>= 1.1.2'
23
24
  spec.add_development_dependency 'minitest', '~> 5.3', '>= 5.3.1'
data/lib/check_disk.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # CheckDisk Version
2
2
  module CheckDisk
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
@@ -0,0 +1,52 @@
1
+ require_relative 'sensu_plugin_helper'
2
+ require 'English'
3
+
4
+ # Unit Test for `bin/check_disk`
5
+ class TestCheckExternal < MiniTest::Test
6
+ include SensuPluginTestHelper
7
+
8
+ def setup
9
+ script 'bin/check_disk.rb'
10
+ end
11
+
12
+ # Warning and Critical at 100%, should exit ok.
13
+ def test_ok
14
+ run_script '-p / -w 100 -c 100'
15
+ assert $CHILD_STATUS.exitstatus == 0, 'Did not exit ok.'
16
+ end
17
+
18
+ # If the disk is more than 1% used we should exit warning.
19
+ def test_warning
20
+ run_script '-p / -c 100 -w 1'
21
+ assert $CHILD_STATUS.exitstatus == 1, 'Did not exit warning.'
22
+ end
23
+
24
+ # If the disk is more than 1% used we should exit critical.
25
+ def test_critical
26
+ run_script '-p / -c 1 -w 100'
27
+ assert $CHILD_STATUS.exitstatus == 2, 'Did not exit critical.'
28
+ end
29
+
30
+ def test_fallthrough
31
+ run_script
32
+ assert $CHILD_STATUS.exitstatus == 1
33
+ end
34
+
35
+ def test_exception
36
+ output = run_script '-f'
37
+ assert $CHILD_STATUS.exitstatus == 2 && output.include?('failed')
38
+ end
39
+
40
+ # Do we see the right message when OK?
41
+ def test_argv
42
+ output = run_script '-p / -w 100 -c 100'
43
+ assert $CHILD_STATUS.exitstatus == 0 && output.include?('threshold')
44
+ end
45
+
46
+ def test_bad_commandline
47
+ output = run_script '--doesnotexist'
48
+ assert $CHILD_STATUS.exitstatus == 2 &&
49
+ output.include?('doesnotexist') &&
50
+ output.include?('invalid option')
51
+ end
52
+ end
@@ -0,0 +1,22 @@
1
+ require 'minitest/autorun'
2
+
3
+ module SensuPluginTestHelper
4
+ def script(script)
5
+ s = Pathname.new(script)
6
+ @script = s.expand_path
7
+ end
8
+
9
+ def run_script(*args)
10
+ IO.popen(([@script] + args).join(' '), 'r+') do |child|
11
+ child.read
12
+ end
13
+ end
14
+
15
+ def run_script_with_input(input, *args)
16
+ IO.popen(([@script] + args).join(' '), 'r+') do |child|
17
+ child.puts input
18
+ child.close_write
19
+ child.read
20
+ end
21
+ end
22
+ end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: check_disk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miah Johnson
@@ -30,7 +30,7 @@ cert_chain:
30
30
  HceOUVz35kgamNj0WW4lNAHyZi7cS0MeI/0B/AGUkaG7gWvyGBAgr1gJ2+4kMmcY
31
31
  vg9xNKI52TEvhr97dNRNTQ==
32
32
  -----END CERTIFICATE-----
33
- date: 2014-08-29 00:00:00.000000000 Z
33
+ date: 2014-09-02 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: sensu-plugin
@@ -161,6 +161,7 @@ extensions: []
161
161
  extra_rdoc_files: []
162
162
  files:
163
163
  - ".gitignore"
164
+ - ".travis.yml"
164
165
  - Gemfile
165
166
  - Makefile
166
167
  - README.md
@@ -172,10 +173,11 @@ files:
172
173
  - lib/check_disk/blocks.rb
173
174
  - lib/check_disk/inodes.rb
174
175
  - lib/check_disk/template.rb
175
- - test/spec/check_disk_spec.rb
176
176
  - test/spec/lib/check_disk/blocks_spec.rb
177
177
  - test/spec/lib/check_disk/inodes_spec.rb
178
178
  - test/spec/spec_helper.rb
179
+ - test/unit/check_disk_unit.rb
180
+ - test/unit/sensu_plugin_helper.rb
179
181
  homepage: https://github.com/SimpleFinance/check_disk
180
182
  licenses:
181
183
  - Apache-2.0
@@ -201,7 +203,8 @@ signing_key:
201
203
  specification_version: 4
202
204
  summary: Sensu CLI Command Check for disk inode and block usage.
203
205
  test_files:
204
- - test/spec/check_disk_spec.rb
205
206
  - test/spec/lib/check_disk/blocks_spec.rb
206
207
  - test/spec/lib/check_disk/inodes_spec.rb
207
208
  - test/spec/spec_helper.rb
209
+ - test/unit/check_disk_unit.rb
210
+ - test/unit/sensu_plugin_helper.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,30 +0,0 @@
1
- require_relative 'spec_helper'
2
- require_relative '../../bin/check_disk'
3
-
4
- describe CheckDisk, '' do
5
- let(:check) { CheckDisk::CLI.new }
6
-
7
- before :each do
8
- @check = check
9
- end
10
-
11
- describe 'Object Ancestry Checks' do
12
- it 'Is a Sensu CLI Check Plugin?' do
13
- @check.must_be_kind_of(Sensu::Plugin::Check::CLI)
14
- end
15
- end
16
-
17
- describe 'Command Line Arguments.' do
18
- it 'Takes in a warning' do
19
- skip
20
- end
21
-
22
- it 'Takes in a critical' do
23
- skip
24
- end
25
-
26
- it 'Takes in a path' do
27
- skip
28
- end
29
- end
30
- end