sensu-plugins-disk-checks 5.0.1 → 5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38d37ef9e41773a99e960a7c802bf7c4f95f50983eb641dfa44b971484e312ba
4
- data.tar.gz: be708ccaf9d3423c4dfd8c5548922cc5e84e93e300f8c33d11be91593a2830d7
3
+ metadata.gz: b13a71fab3c3bc1736ec43012579a6b488f0820b9f9bb14fc7fe404c5bec9a47
4
+ data.tar.gz: 02d51a78c88045e9318b7c75b29b05d5d35c0148ce9960ad9e855ebaa9ee47b5
5
5
  SHA512:
6
- metadata.gz: 297fef7c160a7fc5be856c932f90a667d7fc445dbb4a6ca23e25af0f0ca3d3dd3267a3f21e334a0ecb0b3ff14ab35d18cd2004d849f4ec216489b976d5c95d13
7
- data.tar.gz: bd6238536bf82de618ac8a3de137c7cac5d7150b353b9b109a4cf8a6df6194c4826858665b74a6069e69d486e5556f087688cfb3e1088c9e4af94686438e0f35
6
+ metadata.gz: fb9e68c9c350604b9870fa07b314fb6b3579a907fee4903cc3b8c020a0f97c19f8114ea81716303160a81a4b4b1abbe6f83701f998413244c3e5eff19fe1c92d
7
+ data.tar.gz: 593fa8025e960980e6786f214b20a7f1b86803fb5cdeecf3c59e17a97d8ee74aba4dba90b4092eb65c670af2ab54bf3e77a8457c8c56aab055b4aa03d67f61c2
@@ -5,6 +5,14 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [5.1.0] - 2020-04-22
9
+ ### Changed
10
+ - Updated bundler dependancy to '~> 2.1'
11
+ - Added option to ignore privileged bytes
12
+ - Updated rubocop dependency to '~> 0.81.0'
13
+ - Remediated rubocop issues
14
+ - Updated sys-filesystem gem dependency from 1.3.2 to 1.3.4
15
+
8
16
  ## [5.0.1] - 2019-12-10
9
17
  ### Changed
10
18
  - Updated readme for compliance with proposed plugins style guide
@@ -212,7 +220,8 @@ https://mathias-kettner.de/checkmk_filesystems.html
212
220
  ### Added
213
221
  - initial release
214
222
 
215
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/5.0.1...HEAD
223
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/5.1.0...HEAD
224
+ [5.1.0]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/5.0.1...5.1.0
216
225
  [5.0.1]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/5.0.0...5.0.1
217
226
  [5.0.0]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/4.0.1...5.0.0
218
227
  [4.0.1]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/4.0.0...4.0.1
data/README.md CHANGED
@@ -50,6 +50,7 @@ Usage: check-disk-usage.rb (options)
50
50
  -p PATHRE Ignore mount point(s) matching regular expression
51
51
  -x TYPE[,TYPE] Ignore fs type(s)
52
52
  -I MNT[,MNT] Include only mount point(s)
53
+ -r Ignore bytes reserved for privileged processes only
53
54
  -W PERCENT Warn if PERCENT or more of inodes used
54
55
  -m MAGIC Magic factor to adjust warn/crit thresholds. Example: .9
55
56
  -l MINIMUM Minimum size to adjust (in GB)
@@ -1,4 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  #
3
5
  # check-disk
4
6
  #
@@ -27,12 +29,12 @@
27
29
 
28
30
  require 'sensu-plugin/check/cli'
29
31
  require 'sys/filesystem'
30
- include Sys
31
32
 
32
33
  #
33
34
  # Check Disk
34
35
  #
35
36
  class CheckDisk < Sensu::Plugin::Check::CLI
37
+ include Sys
36
38
  option :fstype,
37
39
  short: '-t TYPE[,TYPE]',
38
40
  description: 'Only check fs type(s)',
@@ -63,6 +65,13 @@ class CheckDisk < Sensu::Plugin::Check::CLI
63
65
  description: 'Ignore option(s)',
64
66
  proc: proc { |a| a.split('.') }
65
67
 
68
+ option :ignore_reserved,
69
+ description: 'Ignore bytes reserved for prvileged processes',
70
+ short: '-r',
71
+ long: '--ignore-reserved',
72
+ boolean: true,
73
+ default: false
74
+
66
75
  option :bwarn,
67
76
  short: '-w PERCENT',
68
77
  description: 'Warn if PERCENT or more of disk full',
@@ -126,10 +135,10 @@ class CheckDisk < Sensu::Plugin::Check::CLI
126
135
  mounts.each do |line|
127
136
  begin
128
137
  next if config[:fstype] && !config[:fstype].include?(line.mount_type)
129
- next if config[:ignoretype] && config[:ignoretype].include?(line.mount_type)
130
- next if config[:ignoremnt] && config[:ignoremnt].include?(line.mount_point)
131
- next if config[:ignorepathre] && config[:ignorepathre].match(line.mount_point)
132
- next if config[:ignoreopt] && config[:ignoreopt].include?(line.options)
138
+ next if config[:ignoretype]&.include?(line.mount_type)
139
+ next if config[:ignoremnt]&.include?(line.mount_point)
140
+ next if config[:ignorepathre]&.match(line.mount_point)
141
+ next if config[:ignoreopt]&.include?(line.options)
133
142
  next if config[:includemnt] && !config[:includemnt].include?(line.mount_point)
134
143
  rescue StandardError
135
144
  unknown 'An error occured getting the mount info'
@@ -157,6 +166,7 @@ class CheckDisk < Sensu::Plugin::Check::CLI
157
166
  if line.mount_type == 'devfs'
158
167
  return
159
168
  end
169
+
160
170
  if fs_info.respond_to?(:inodes) && !fs_info.inodes.nil? # needed for windows
161
171
  percent_i = percent_inodes(fs_info)
162
172
  if percent_i >= config[:icrit]
@@ -185,9 +195,9 @@ class CheckDisk < Sensu::Plugin::Check::CLI
185
195
  end
186
196
  end
187
197
 
188
- def to_human(s)
189
- unit = [[1_099_511_627_776, 'TiB'], [1_073_741_824, 'GiB'], [1_048_576, 'MiB'], [1024, 'KiB'], [0, 'B']].detect { |u| s >= u[0] }
190
- format("%.2f #{unit[1]}", (s >= 1024 ? s.to_f / unit[0] : s))
198
+ def to_human(size)
199
+ unit = [[1_099_511_627_776, 'TiB'], [1_073_741_824, 'GiB'], [1_048_576, 'MiB'], [1024, 'KiB'], [0, 'B']].detect { |u| size >= u[0] }
200
+ format("%.2f #{unit[1]}", (size >= 1024 ? size.to_f / unit[0] : size))
191
201
  end
192
202
 
193
203
  # Determine the percent inode usage
@@ -199,7 +209,11 @@ class CheckDisk < Sensu::Plugin::Check::CLI
199
209
  # Determine the percent byte usage
200
210
  #
201
211
  def percent_bytes(fs_info)
202
- (100.0 - (100.0 * fs_info.bytes_free / fs_info.bytes_total)).round(2)
212
+ if config[:ignore_reserved]
213
+ (100.0 - (100.0 * fs_info.bytes_available / fs_info.bytes_total)).round(2)
214
+ else
215
+ (100.0 - (100.0 * fs_info.bytes_free / fs_info.bytes_total)).round(2)
216
+ end
203
217
  end
204
218
 
205
219
  # Generate output
@@ -1,4 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  #
3
5
  # check-fstab-mounts
4
6
  #
@@ -51,30 +53,30 @@ class CheckFstabMounts < Sensu::Plugin::Check::CLI
51
53
  @missing_mounts = []
52
54
  end
53
55
 
54
- def resolve_device(d)
55
- if d.start_with?('UUID=')
56
- uuid = d.split('=')[1]
56
+ def resolve_device(dev)
57
+ if dev.start_with?('UUID=')
58
+ uuid = dev.split('=')[1]
57
59
  path = File.join('/', 'dev', 'disk', 'by-uuid', uuid)
58
60
  if File.exist?(path) && File.symlink?(path)
59
61
  return File.realpath(path)
60
62
  end
61
63
  end
62
64
 
63
- if d.start_with?('LABEL=')
64
- label = d.split('=')[1]
65
+ if dev.start_with?('LABEL=')
66
+ label = dev.split('=')[1]
65
67
  path = File.join('/', 'dev', 'disk', 'by-label', label)
66
68
  if File.exist?(path) && File.symlink?(path)
67
69
  return File.realpath(path)
68
70
  end
69
71
  end
70
72
 
71
- if d.start_with?('/dev/mapper')
72
- if File.symlink?(d)
73
- d = File.realpath(d, '/')
73
+ if dev.start_with?('/dev/mapper')
74
+ if File.symlink?(dev)
75
+ dev = File.realpath(dev, '/')
74
76
  end
75
77
  end
76
78
 
77
- d
79
+ dev
78
80
  end
79
81
 
80
82
  # Check by mount destination (col 2 in fstab and proc/mounts)
@@ -83,6 +85,7 @@ class CheckFstabMounts < Sensu::Plugin::Check::CLI
83
85
  @fstab.each do |line|
84
86
  next if line =~ /^\s*#/
85
87
  next if line =~ /^\s*$/
88
+
86
89
  fields = line.split(/\s+/)
87
90
  next if fields[1] == 'none' || (fields[3].include? 'noauto')
88
91
  next if config[:fstypes] && !config[:fstypes].include?(fields[2])
@@ -1,4 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  #
3
5
  # check-smart
4
6
  #
@@ -82,6 +84,7 @@ class Disk
82
84
 
83
85
  def smart_ignore?(num)
84
86
  return if @att_ignore.nil?
87
+
85
88
  @att_ignore.include? num
86
89
  end
87
90
 
@@ -163,6 +166,7 @@ class SmartCheckStatus < Sensu::Plugin::Check::CLI
163
166
  # Set default threshold
164
167
  default_threshold = config[:defaults].split(',')
165
168
  raise 'Invalid default threshold parameter count' unless default_threshold.size == 4
169
+
166
170
  @smart_attributes.each do |att|
167
171
  att[:crit_min] = default_threshold[0].to_i if att[:crit_min].nil?
168
172
  att[:warn_min] = default_threshold[1].to_i if att[:warn_min].nil?
@@ -1,4 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  #
3
5
  # check-smart-tests.rb
4
6
  #
@@ -78,7 +80,7 @@ end
78
80
 
79
81
  class CheckSMARTTests < Sensu::Plugin::Check::CLI
80
82
  option :executable,
81
- long: '--executable EXECUTABLE',
83
+ long: '--executable EXECUTABLE',
82
84
  short: '-e EXECUTABLE',
83
85
  default: '/usr/sbin/smartctl',
84
86
  description: 'Path to smartctl executable'
@@ -1,4 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  #
3
5
  # check-smart
4
6
  #
@@ -169,7 +171,7 @@ class CheckSMART < Sensu::Plugin::Check::CLI
169
171
  # Main function
170
172
  #
171
173
  def run
172
- unless @devices.length > 0
174
+ unless @devices.length > 0 # rubocop: disable Style/NumericPredicate
173
175
  exit_with(
174
176
  config[:no_smart_capable_disks],
175
177
  'No SMART capable devices found'
@@ -179,13 +181,13 @@ class CheckSMART < Sensu::Plugin::Check::CLI
179
181
  unhealthy_disks = @devices.select { |disk| disk.smart_capable? && !disk.healthy? }
180
182
  unknown_disks = @devices.reject(&:smart_capable?)
181
183
 
182
- if unhealthy_disks.length > 0
184
+ if unhealthy_disks.length > 0 # rubocop: disable Style/NumericPredicate
183
185
  output = unhealthy_disks.map(&:health_output)
184
186
  output.concat(unknown_disks.map(&:capability_output))
185
187
  critical output.join("\n")
186
188
  end
187
189
 
188
- if unknown_disks.length > 0
190
+ if unknown_disks.length > 0 # rubocop: disable Style/NumericPredicate
189
191
  exit_with(
190
192
  config[:smart_incapable_disks],
191
193
  unknown_disks.map(&:capability_output).join("\n")
@@ -1,4 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  #
3
5
  # disk-capacity-metrics
4
6
  #
@@ -47,7 +49,7 @@ class DiskCapacity < Sensu::Plugin::Metric::CLI::Graphite
47
49
  begin
48
50
  converted = Integer(value)
49
51
  values[index] = converted
50
- rescue ArgumentError # rubocop:disable HandleExceptions
52
+ rescue ArgumentError # rubocop:disable Lint/SuppressedException
51
53
  end
52
54
  end
53
55
  values
@@ -1,4 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  #
3
5
  # disk-usage-metrics
4
6
  #
@@ -105,8 +107,9 @@ class DiskUsageMetrics < Sensu::Plugin::Metric::CLI::Graphite
105
107
  _, _, used, avail, used_p, mnt = line.split
106
108
 
107
109
  unless %r{/sys[/|$]|/dev[/|$]|/run[/|$]} =~ mnt
108
- next if config[:ignore_mnt] && config[:ignore_mnt].find { |x| mnt.match(x) }
110
+ next if config[:ignore_mnt]&.find { |x| mnt.match(x) }
109
111
  next if config[:include_mnt] && !config[:include_mnt].find { |x| mnt.match(x) }
112
+
110
113
  mnt = if config[:flatten]
111
114
  mnt.eql?('/') ? 'root' : mnt.gsub(/^\//, '')
112
115
  else
@@ -1,4 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  #
3
5
  # disk-metrics
4
6
  #
@@ -75,7 +77,7 @@ class DiskGraphite < Sensu::Plugin::Metric::CLI::Graphite
75
77
  end
76
78
  next if stats == ['0'].cycle.take(stats.size)
77
79
 
78
- next if config[:ignore_device] && config[:ignore_device].find { |x| dev.match(x) }
80
+ next if config[:ignore_device]&.find { |x| dev.match(x) }
79
81
  next if config[:include_device] && !config[:include_device].find { |x| dev.match(x) }
80
82
 
81
83
  metrics.size.times { |i| output "#{config[:scheme]}.#{dev}.#{metrics[i]}", stats[i] }
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'sensu-plugins-disk-checks/version'
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SensuPluginsDiskChecks
2
4
  module Version
3
5
  MAJOR = 5
4
- MINOR = 0
5
- PATCH = 1
6
+ MINOR = 1
7
+ PATCH = 0
6
8
 
7
9
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-disk-checks
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.1
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-11 00:00:00.000000000 Z
11
+ date: 2020-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 1.3.2
33
+ version: 1.3.4
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 1.3.2
40
+ version: 1.3.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.7'
47
+ version: '2.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.7'
54
+ version: '2.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: codeclimate-test-reporter
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 0.51.0
145
+ version: 0.81.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 0.51.0
152
+ version: 0.81.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: yard
155
155
  requirement: !ruby/object:Gem::Requirement