check_disk 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b755cacc90b2df969b93ee370d04da3bd23806b
4
+ data.tar.gz: cf515342fb6a4cd7696feec1e4c4fed166775146
5
+ SHA512:
6
+ metadata.gz: 71556149db3ca216e8906077dfe7bac59dd9ac29b94629482e3a73031a3592ee375781d58e4edb87183224920047062e64e5af91b649dce35bf9fddd4f621243
7
+ data.tar.gz: 12d75b592527d1e9c6773fab67589563d8d04f3658461960b2757ef335418a7514d596c6508e3e3769f5da88e3d00f459bf550fa09c721008c09638a98da4fe5
Binary file
Binary file
@@ -0,0 +1,35 @@
1
+ .gem*
2
+ *.gem
3
+ *.rbc
4
+ /.config
5
+ /coverage/
6
+ /InstalledFiles
7
+ /pkg/
8
+ /spec/reports/
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ ## Specific to RubyMotion:
14
+ .dat*
15
+ .repl_history
16
+ build/
17
+
18
+ ## Documentation cache and generated files:
19
+ /.yardoc/
20
+ /_yardoc/
21
+ /doc/
22
+ /rdoc/
23
+
24
+ ## Environment normalisation:
25
+ /.bundle/
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,10 @@
1
+ RUBY_GEMS ?= .gems
2
+
3
+ bundle_tasks:
4
+ bundle config build.nokogiri --use-system-libraries
5
+
6
+ bundle_install: bundle_tasks
7
+ bundle install --jobs 4 --quiet --path=$(RUBY_GEMS)
8
+
9
+ test: bundle_install
10
+ bundle exec rake test:all
@@ -0,0 +1,56 @@
1
+ check_disk
2
+ ==========
3
+
4
+ * A sensu check for disks.
5
+ * A Sensu Plugin to check disk block and inode usage by mountpoint.
6
+ * Takes a mount point in as `path`.
7
+ * Takes warning, and critical parameters that set a percentage [0-100].
8
+ * Takes parameters to check either file serial numbers (inodes) _or_ blocks.
9
+ * Determines `total number` of inodes|blocks.
10
+ * Determines baseline `percent` based on `total number`.
11
+ * Determines usage by subtracting `available` from `total number`
12
+ * Compares usage to see if greater than baseline.
13
+
14
+ See: statvfs(3)
15
+ See: [https://github.com/djberg96/sys-filesystem](https://github.com/djberg96/sys-filesystem)
16
+
17
+ "Because parsing the output of `df` is a bad idea."
18
+
19
+ # Install
20
+
21
+ This project is laid out as a Ruby Gem.
22
+
23
+ You can add this repository to your Gemfile, or create a gem and install that.
24
+
25
+ # Use
26
+
27
+ ```
28
+ check_disk.rb -h
29
+ Usage: check_disk.rb (options)
30
+ -b Boolean for enabling block code path.
31
+ -c PERCENT The high water mark for `critical` alerts. eg; 75
32
+ -i Boolean for enabling inode code path.
33
+ -p PATH The `path` or `mount point` we are checking. eg; /mnt
34
+ -w PERCENT The high water mark for `warning` alerts. eg; 50
35
+ ```
36
+
37
+ ```
38
+ $ check_disk.rb -i
39
+ CheckDisk::CLI WARNING: 65% of inodes used. path: / total: 121846308 available: 42055237
40
+ ```
41
+
42
+ # Build
43
+
44
+ `gem build check_disk.gemspec`
45
+
46
+ # Test
47
+
48
+ `make test`
49
+
50
+ or
51
+
52
+ `bundle exec rake test:all`
53
+
54
+ ## Coverage
55
+
56
+ View test coverage executing `make test` then opening `coverage/index.html`
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+ require 'rubocop/rake_task'
6
+ require 'bundler'
7
+
8
+ Bundler.setup
9
+
10
+ task default: 'test:all'
11
+
12
+ namespace :test do
13
+ Rake::TestTask.new do |t|
14
+ t.name = :minitest
15
+ t.test_files = Dir.glob('test/**/**/*_{spec,unit}.rb')
16
+ end
17
+
18
+ desc 'Run RuboCop on the lib directory'
19
+ RuboCop::RakeTask.new do |t|
20
+ t.name = :rubocop
21
+ t.patterns = [
22
+ 'lib/**/*.rb',
23
+ 'test/**/*.rb',
24
+ 'bin/check_disk.rb',
25
+ 'Rakefile',
26
+ 'Gemfile'
27
+ ]
28
+ t.fail_on_error = false
29
+ end
30
+
31
+ desc 'Run all of the tests.'
32
+ task :all do
33
+ Rake::Task['test:rubocop'].invoke
34
+ Rake::Task['test:minitest'].invoke
35
+ end
36
+ end
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'sensu-plugin/check/cli'
4
+ require 'check_disk/blocks'
5
+ require 'check_disk/inodes'
6
+
7
+ module CheckDisk
8
+ # A Sensu Plugin to check disk block and inode usage by mountpoint.
9
+ # Takes a mount point in as `path`.
10
+ # Takes warning, and critical parameters that set a percentage [0-100].
11
+ # Takes parameters to check either file serial numbers (inodes) _or_ blocks.
12
+ # Determines `total number` of inodes|blocks.
13
+ # Determines baseline `percent` based on `total number`.
14
+ # Determines usage by subtracting `available` from `total number`
15
+ # Compares usage to see if greater than baseline.
16
+ #
17
+ # See: statvfs(3)
18
+ # See: https://github.com/djberg96/sys-filesystem
19
+ #
20
+ # "Because parsing the output of `df` is a bad idea."
21
+ class CLI < Sensu::Plugin::Check::CLI
22
+ def initialize
23
+ super
24
+ end
25
+
26
+ # Sensu check run loop.
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`.'
31
+ end
32
+
33
+ def check_blocks
34
+ disk = CheckDisk::Block.new(config)
35
+ common_check(disk)
36
+ end
37
+
38
+ def check_inodes
39
+ disk = CheckDisk::Inode.new(config)
40
+ common_check(disk)
41
+ end
42
+
43
+ def common_check(disk)
44
+ message(disk.message)
45
+ warning if disk.warning?
46
+ critical if disk.critical?
47
+ ok
48
+ end
49
+
50
+ private
51
+
52
+ # Adds a `-p` or `--path` option to our CLI.
53
+ # Sets `config[:path]`
54
+ # @return [String] The `path` or `mount point` we are checking.
55
+ option(
56
+ :path,
57
+ short: '-p PATH',
58
+ default: '/',
59
+ description: 'The `path` or `mount point` we are checking. eg; /mnt'
60
+ )
61
+
62
+ # Adds a `--inodes` option to our CLI.
63
+ # Sets `config[:inodes]`
64
+ # @return [TrueClass, FalseClass] Boolean for enabling inode code path.
65
+ option(
66
+ :inodes,
67
+ short: '-i',
68
+ boolean: true,
69
+ description: 'Boolean for enabling inode code path.'
70
+ )
71
+
72
+ # Adds a `--blocks` option to our CLI.
73
+ # Sets `config[:blocks]`
74
+ # @return [TrueClass, FalseClass] Boolean for enabling block code path.
75
+ option(
76
+ :blocks,
77
+ short: '-b',
78
+ boolean: true,
79
+ description: 'Boolean for enabling block code path.'
80
+ )
81
+
82
+ # Adds a `-w` or `--warning` option to our CLI.
83
+ # Sets `config[:warning]`
84
+ # @return [Fixnum] The high water mark for `warning` alerts.
85
+ option(
86
+ :warning,
87
+ short: '-w PERCENT',
88
+ proc: proc { |a| a.to_i },
89
+ default: 50,
90
+ description: 'The high water mark for `warning` alerts. eg; 50'
91
+ )
92
+
93
+ # Adds a `-c` or `--critical` option to our CLI.
94
+ # Sets `config[:critical]`
95
+ # @return [Fixnum] The high water mark for `critical` alerts.
96
+ option(
97
+ :critical,
98
+ short: '-c PERCENT',
99
+ proc: proc { |a| a.to_i },
100
+ default: 75,
101
+ description: 'The high water mark for `critical` alerts. eg; 75'
102
+ )
103
+ end
104
+ end
@@ -0,0 +1,21 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDbDCCAlSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MQ0wCwYDVQQDDARtaWFo
3
+ MRgwFgYKCZImiZPyLGQBGRYIY2hpYS1wZXQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
4
+ HhcNMTQwODA4MjM1OTA1WhcNMTUwODA4MjM1OTA1WjA+MQ0wCwYDVQQDDARtaWFo
5
+ MRgwFgYKCZImiZP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----
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ require_relative 'lib/check_disk'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'check_disk'
6
+ spec.version = CheckDisk::VERSION
7
+ spec.authors = ['Miah Johnson']
8
+ spec.email = %w(miah@chia-pet.org)
9
+ spec.description = 'Sensu/Nagios CLI Command Check for disk' \
10
+ ' inode and block usage.'
11
+ spec.summary = 'Sensu CLI Command Check for disk inode and block usage.'
12
+ spec.homepage = 'https://github.com/SimpleFinance/check_disk'
13
+ spec.license = 'Apache-2.0'
14
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
15
+ spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(/^(test|spec|features)/)
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
+
21
+ spec.add_runtime_dependency 'sensu-plugin', '~> 0.3', '>= 0.3.0'
22
+ spec.add_runtime_dependency 'sys-filesystem', '~> 1.1', '>= 1.1.2'
23
+ spec.add_development_dependency 'minitest', '~> 5.3', '>= 5.3.1'
24
+ spec.add_development_dependency 'rake', '~> 10.3', '>= 10.3.0'
25
+ spec.add_development_dependency 'rubocop', '~> 0.20', '>= 0.20.1'
26
+ spec.add_development_dependency 'simplecov', '~> 0.8', '>= 0.8.2'
27
+ end
@@ -0,0 +1,4 @@
1
+ # CheckDisk Version
2
+ module CheckDisk
3
+ VERSION = '0.1.0'
4
+ end
@@ -0,0 +1,66 @@
1
+ require 'check_disk/template'
2
+
3
+ module CheckDisk
4
+ # Interface for checking Inodes.
5
+ class Block < CheckDisk::Template
6
+ def initialize(config)
7
+ super
8
+ end
9
+
10
+ def total
11
+ blocks_total
12
+ end
13
+
14
+ def available
15
+ blocks_available
16
+ end
17
+
18
+ def used
19
+ blocks_used
20
+ end
21
+
22
+ def percent_used
23
+ percent_of_blocks_used
24
+ end
25
+
26
+ # Boolean method for determining if we are 'warning?'
27
+ # @return [TrueClass, FalseClass] Warning True or False?
28
+ def warning?
29
+ percent_of_blocks_used > warning
30
+ end
31
+
32
+ # Boolean method for determining if we are 'critical?'
33
+ # @return [TrueClass, FalseClass] Critical True or False?
34
+ def critical?
35
+ percent_of_blocks_used > critical
36
+ end
37
+
38
+ def message
39
+ "#{ percent_of_blocks_used }% of blocks used. " \
40
+ "path: #{ path } total: #{ total } available: #{ available }"
41
+ end
42
+
43
+ private
44
+
45
+ # @return [Fixnum] number of available blocks.
46
+ def blocks_available
47
+ path_stat.blocks_available
48
+ end
49
+
50
+ # @return [Fixnum] total number of blocks.
51
+ def blocks_total
52
+ path_stat.blocks
53
+ end
54
+
55
+ # @return [Fixnum] total number of blocks used.
56
+ def blocks_used
57
+ blocks_total - blocks_available
58
+ end
59
+
60
+ # @param percent [Fixnum] the percentage to check.
61
+ # @return [Fixnum] computed blocks used by percent.
62
+ def percent_of_blocks_used
63
+ percent_of(blocks_total, blocks_used)
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,61 @@
1
+ require 'check_disk/template'
2
+
3
+ module CheckDisk
4
+ # Interface for checking Inodes.
5
+ class Inode < CheckDisk::Template
6
+ def initialize(config)
7
+ super
8
+ end
9
+
10
+ def total
11
+ inodes_total
12
+ end
13
+
14
+ def available
15
+ inodes_available
16
+ end
17
+
18
+ def used
19
+ inodes_used
20
+ end
21
+
22
+ def percent_used
23
+ percent_of_inodes_used
24
+ end
25
+
26
+ def warning?
27
+ percent_of_inodes_used > warning
28
+ end
29
+
30
+ def critical?
31
+ percent_of_inodes_used > critical
32
+ end
33
+
34
+ def message
35
+ "#{ percent_of_inodes_used }% of inodes used. " \
36
+ "path: #{ path } total: #{ total } available: #{ available }"
37
+ end
38
+
39
+ private
40
+
41
+ # @return [Fixnum] total number of file serial numbers (inodes).
42
+ def inodes_total
43
+ path_stat.files
44
+ end
45
+
46
+ # @return [Fixnum] number of available file serial numbers (inodes).
47
+ def inodes_available
48
+ path_stat.files_available
49
+ end
50
+
51
+ # @return [Fixnum] total number of inodes used.
52
+ def inodes_used
53
+ inodes_total - inodes_available
54
+ end
55
+
56
+ # @return [Fixnum] computed inodes used by percent.
57
+ def percent_of_inodes_used
58
+ percent_of(inodes_total, inodes_used)
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,41 @@
1
+ require 'sys/filesystem'
2
+
3
+ module CheckDisk
4
+ # Interface for checking Inodes.
5
+ class Template
6
+ def initialize(config)
7
+ @config = config
8
+ end
9
+
10
+ include Sys
11
+
12
+ private
13
+
14
+ # in-line convert to float so we get '0.<some percent>'
15
+ # convert our result back to integer to drop the remainder.
16
+ # @return [Fixnum] percentage of amount
17
+ def percent_of(total, used)
18
+ ((used.to_f / total.to_f) * 100).to_i
19
+ end
20
+
21
+ # @return [Sys::Filesystem::Stat] a data structure about our filesystem.
22
+ def path_stat
23
+ @fs ||= Filesystem.stat(path)
24
+ end
25
+
26
+ # @return [String] The path passed in (or its default).
27
+ def path
28
+ @config[:path]
29
+ end
30
+
31
+ # @return [Fixnum] The warning passed in.
32
+ def warning
33
+ @config[:warning]
34
+ end
35
+
36
+ # @return [Fixnum] The critical passed in.
37
+ def critical
38
+ @config[:critical]
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,30 @@
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
@@ -0,0 +1,93 @@
1
+ require_relative '../../spec_helper'
2
+ require 'check_disk/blocks'
3
+ require 'ostruct'
4
+
5
+ describe CheckDisk::Block, '' do
6
+ let(:check) { CheckDisk::Block.new(config) }
7
+
8
+ # Sensu CLI would send our program a hash of configuration options.
9
+ # @return [Hash] our mock 'config'
10
+ let(:config) do
11
+ {
12
+ path: '/',
13
+ warning: 50,
14
+ critical: 75
15
+ }
16
+ end
17
+
18
+ # @return [OpenStruct] a mock object containing some of the output of a
19
+ # Sys::Filesystem::Stat
20
+ let(:filesystem) do
21
+ OpenStruct.new(
22
+ blocks: 121_846_310,
23
+ blocks_available: 42_461_553
24
+ )
25
+ end
26
+
27
+ describe 'Object Ancestry Checks' do
28
+ it 'Is a Sensu CLI Check Plugin?' do
29
+ check.must_be_kind_of(CheckDisk::Block)
30
+ end
31
+ end
32
+
33
+ # This test should be moved to a unit test.
34
+ # It tests a method provided by the template
35
+ # It modifies class internals to test.
36
+ describe 'Discovers filesystem details.' do
37
+ it 'Can discover the filesystem.' do
38
+ module CheckDisk
39
+ # Adds a public method to gain access to a private method for testing.
40
+ class Block
41
+ def filesystem_details
42
+ path_stat
43
+ end
44
+ end
45
+ end
46
+
47
+ check.must_respond_to(:filesystem_details)
48
+ check.filesystem_details.must_be_instance_of(Sys::Filesystem::Stat)
49
+ end
50
+
51
+ it 'Can find total number of blocks.' do
52
+ check.must_respond_to(:total)
53
+ check.stub :path_stat, (filesystem) do
54
+ check.total.must_equal(filesystem.blocks)
55
+ end
56
+ end
57
+
58
+ it 'Can find blocks available.' do
59
+ check.must_respond_to(:available)
60
+ check.stub :path_stat, (filesystem) do
61
+ check.available.must_equal(filesystem.blocks_available)
62
+ end
63
+ end
64
+
65
+ it 'Can find blocks used.' do
66
+ check.must_respond_to(:used)
67
+ check.stub :path_stat, (filesystem) do
68
+ check.used.must_equal(79_384_757)
69
+ end
70
+ end
71
+
72
+ it 'Can find percent of blocks used.' do
73
+ check.must_respond_to(:percent_used)
74
+ check.stub :path_stat, (filesystem) do
75
+ check.percent_used.must_equal(65)
76
+ end
77
+ end
78
+
79
+ it 'Can tell us if we are warning?' do
80
+ check.must_respond_to(:warning?)
81
+ check.stub :path_stat, (filesystem) do
82
+ check.warning?.must_equal(true)
83
+ end
84
+ end
85
+
86
+ it 'Can tell us if we are critical?' do
87
+ check.must_respond_to(:warning?)
88
+ check.stub :path_stat, (filesystem) do
89
+ check.critical?.must_equal(false)
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,92 @@
1
+ require_relative '../../spec_helper'
2
+ require 'check_disk/inodes'
3
+ require 'ostruct'
4
+
5
+ describe CheckDisk::Inode, '' do
6
+ let(:check) { CheckDisk::Inode.new(config) }
7
+
8
+ # Sensu CLI would send our program a hash of configuration options.
9
+ # @return [Hash] our mock 'config'
10
+ let(:config) do
11
+ {
12
+ path: '/',
13
+ warning: 50,
14
+ critical: 75
15
+ }
16
+ end
17
+
18
+ # @return [OpenStruct] a mock object containing some of the output of a
19
+ # Sys::Filesystem::Stat
20
+ let(:filesystem) do
21
+ OpenStruct.new(
22
+ files: 121_846_308,
23
+ files_available: 42_461_553
24
+ )
25
+ end
26
+
27
+ describe 'Object Ancestry Checks' do
28
+ it 'Is a Sensu CLI Check Plugin?' do
29
+ check.must_be_kind_of(CheckDisk::Inode)
30
+ end
31
+ end
32
+
33
+ # This test should be moved to a unit test.
34
+ # It tests a method provided by the template
35
+ # It modifies class internals to test.
36
+ describe 'Discovers filesystem details.' do
37
+ it 'Can discover the filesystem.' do
38
+ module CheckDisk
39
+ # Adds a public method to gain access to a private method for testing.
40
+ class Inode
41
+ def filesystem_details
42
+ path_stat
43
+ end
44
+ end
45
+ end
46
+
47
+ check.must_respond_to(:filesystem_details)
48
+ check.filesystem_details.must_be_instance_of(Sys::Filesystem::Stat)
49
+ end
50
+ it 'Can find total number of inodes.' do
51
+ check.must_respond_to(:total)
52
+ check.stub :path_stat, (filesystem) do
53
+ check.total.must_equal(121_846_308)
54
+ end
55
+ end
56
+
57
+ it 'Can find inodes available.' do
58
+ check.must_respond_to(:available)
59
+ check.stub :path_stat, (filesystem) do
60
+ check.available.must_equal(42_461_553)
61
+ end
62
+ end
63
+
64
+ it 'Can find inodes used.' do
65
+ check.must_respond_to(:used)
66
+ check.stub :path_stat, (filesystem) do
67
+ check.used.must_equal(79_384_755)
68
+ end
69
+ end
70
+
71
+ it 'Can find percent of inodes used.' do
72
+ check.must_respond_to(:percent_used)
73
+ check.stub :path_stat, (filesystem) do
74
+ check.percent_used.must_equal(65)
75
+ end
76
+ end
77
+
78
+ it 'Can tell us if we are warning?' do
79
+ check.must_respond_to(:warning?)
80
+ check.stub :path_stat, (filesystem) do
81
+ check.warning?.must_equal(true)
82
+ end
83
+ end
84
+
85
+ it 'Can tell us if we are critical?' do
86
+ check.must_respond_to(:warning?)
87
+ check.stub :path_stat, (filesystem) do
88
+ check.critical?.must_equal(false)
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,11 @@
1
+ unless ENV['TRAVIS']
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter '/.gems/'
5
+ add_filter '/test/'
6
+ end
7
+ end
8
+
9
+ require 'minitest/autorun'
10
+
11
+ Minitest::Test.parallelize_me!
metadata ADDED
@@ -0,0 +1,207 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: check_disk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Miah Johnson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDbDCCAlSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MQ0wCwYDVQQDDARtaWFo
14
+ MRgwFgYKCZImiZPyLGQBGRYIY2hpYS1wZXQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
15
+ HhcNMTQwODA4MjM1OTA1WhcNMTUwODA4MjM1OTA1WjA+MQ0wCwYDVQQDDARtaWFo
16
+ MRgwFgYKC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FICATE-----
33
+ date: 2014-08-29 00:00:00.000000000 Z
34
+ dependencies:
35
+ - !ruby/object:Gem::Dependency
36
+ name: sensu-plugin
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0.3'
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 0.3.0
45
+ type: :runtime
46
+ prerelease: false
47
+ version_requirements: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - "~>"
50
+ - !ruby/object:Gem::Version
51
+ version: '0.3'
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.3.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: sys-filesystem
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 1.1.2
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '1.1'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 1.1.2
75
+ - !ruby/object:Gem::Dependency
76
+ name: minitest
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '5.3'
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 5.3.1
85
+ type: :development
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '5.3'
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 5.3.1
95
+ - !ruby/object:Gem::Dependency
96
+ name: rake
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '10.3'
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 10.3.0
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '10.3'
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: 10.3.0
115
+ - !ruby/object:Gem::Dependency
116
+ name: rubocop
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - "~>"
120
+ - !ruby/object:Gem::Version
121
+ version: '0.20'
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 0.20.1
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.20'
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 0.20.1
135
+ - !ruby/object:Gem::Dependency
136
+ name: simplecov
137
+ requirement: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - "~>"
140
+ - !ruby/object:Gem::Version
141
+ version: '0.8'
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: 0.8.2
145
+ type: :development
146
+ prerelease: false
147
+ version_requirements: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '0.8'
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: 0.8.2
155
+ description: Sensu/Nagios CLI Command Check for disk inode and block usage.
156
+ email:
157
+ - miah@chia-pet.org
158
+ executables:
159
+ - check_disk.rb
160
+ extensions: []
161
+ extra_rdoc_files: []
162
+ files:
163
+ - ".gitignore"
164
+ - Gemfile
165
+ - Makefile
166
+ - README.md
167
+ - Rakefile
168
+ - bin/check_disk.rb
169
+ - certs/miah_johnson.pem
170
+ - check_disk.gemspec
171
+ - lib/check_disk.rb
172
+ - lib/check_disk/blocks.rb
173
+ - lib/check_disk/inodes.rb
174
+ - lib/check_disk/template.rb
175
+ - test/spec/check_disk_spec.rb
176
+ - test/spec/lib/check_disk/blocks_spec.rb
177
+ - test/spec/lib/check_disk/inodes_spec.rb
178
+ - test/spec/spec_helper.rb
179
+ homepage: https://github.com/SimpleFinance/check_disk
180
+ licenses:
181
+ - Apache-2.0
182
+ metadata: {}
183
+ post_install_message:
184
+ rdoc_options: []
185
+ require_paths:
186
+ - lib
187
+ required_ruby_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ required_rubygems_version: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
197
+ requirements: []
198
+ rubyforge_project:
199
+ rubygems_version: 2.4.1
200
+ signing_key:
201
+ specification_version: 4
202
+ summary: Sensu CLI Command Check for disk inode and block usage.
203
+ test_files:
204
+ - test/spec/check_disk_spec.rb
205
+ - test/spec/lib/check_disk/blocks_spec.rb
206
+ - test/spec/lib/check_disk/inodes_spec.rb
207
+ - test/spec/spec_helper.rb
Binary file