sensu-plugins-disk-checks 5.0.1 → 5.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38d37ef9e41773a99e960a7c802bf7c4f95f50983eb641dfa44b971484e312ba
4
- data.tar.gz: be708ccaf9d3423c4dfd8c5548922cc5e84e93e300f8c33d11be91593a2830d7
3
+ metadata.gz: f2c5f3e7cb7dc768ff1903d561a3aaedcd2d2298ca3e7d6ba7782f504fa8d31c
4
+ data.tar.gz: b728133e6f2082c0a5454f730caa9dee13248f3104ffd8ee1610913f81f7aff5
5
5
  SHA512:
6
- metadata.gz: 297fef7c160a7fc5be856c932f90a667d7fc445dbb4a6ca23e25af0f0ca3d3dd3267a3f21e334a0ecb0b3ff14ab35d18cd2004d849f4ec216489b976d5c95d13
7
- data.tar.gz: bd6238536bf82de618ac8a3de137c7cac5d7150b353b9b109a4cf8a6df6194c4826858665b74a6069e69d486e5556f087688cfb3e1088c9e4af94686438e0f35
6
+ metadata.gz: 12f3b53ded7a8a036573176976e5e9dceeda4a9886ace306dd88b46bf2dfd54c5bf36523cb6c2976024cd6c2b176a19cdac284c49f8ec57115599055215bfbf8
7
+ data.tar.gz: 7e17b7dd33bfebf3d6ebd7253036e3982cb17b3a92241dc13248cc72c1f6ec030e1d4d9ca3067d9974614f56402711a065e130237204bba1165ef3491bacc564
@@ -5,6 +5,30 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [5.1.4] - 2020-11-05
9
+ ### Fixed
10
+ - change Sensu asset build definition to match ruby-runtime build collection. No change to underlying plugin functionality
11
+
12
+ ## [5.1.3] - 2020-06-02
13
+ ### Fixed
14
+ - fix for incorrect Ruby literal string freeze in binaries
15
+
16
+ ## [5.1.2] - 2020-05-20
17
+ ### Fixed
18
+ - check-disk-usage.rb: More accurate disk percent usage ignoring privileged bytes (@SaviourSelf)
19
+
20
+ ## [5.1.1] - 2020-04-22
21
+ ### Changed
22
+ - Removed centos from .bonsai.yml to make Bonsai happy again
23
+
24
+ ## [5.1.0] - 2020-04-22
25
+ ### Changed
26
+ - Updated bundler dependancy to '~> 2.1'
27
+ - Added option to ignore privileged bytes
28
+ - Updated rubocop dependency to '~> 0.81.0'
29
+ - Remediated rubocop issues
30
+ - Updated sys-filesystem gem dependency from 1.3.2 to 1.3.4
31
+
8
32
  ## [5.0.1] - 2019-12-10
9
33
  ### Changed
10
34
  - Updated readme for compliance with proposed plugins style guide
@@ -212,7 +236,11 @@ https://mathias-kettner.de/checkmk_filesystems.html
212
236
  ### Added
213
237
  - initial release
214
238
 
215
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/5.0.1...HEAD
239
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/5.1.3...HEAD
240
+ [5.1.3]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/5.1.2...5.1.3
241
+ [5.1.2]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/5.1.1...5.1.2
242
+ [5.1.1]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/5.1.0...5.1.1
243
+ [5.1.0]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/5.0.1...5.1.0
216
244
  [5.0.1]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/5.0.0...5.0.1
217
245
  [5.0.0]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/4.0.1...5.0.0
218
246
  [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: false
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,19 @@ class CheckDisk < Sensu::Plugin::Check::CLI
63
65
  description: 'Ignore option(s)',
64
66
  proc: proc { |a| a.split('.') }
65
67
 
68
+ option :ignorereadonly,
69
+ long: '--ignore-readonly',
70
+ description: 'Ignore read-only filesystems',
71
+ boolean: true,
72
+ default: false
73
+
74
+ option :ignore_reserved,
75
+ description: 'Ignore bytes reserved for privileged processes',
76
+ short: '-r',
77
+ long: '--ignore-reserved',
78
+ boolean: true,
79
+ default: false
80
+
66
81
  option :bwarn,
67
82
  short: '-w PERCENT',
68
83
  description: 'Warn if PERCENT or more of disk full',
@@ -126,10 +141,11 @@ class CheckDisk < Sensu::Plugin::Check::CLI
126
141
  mounts.each do |line|
127
142
  begin
128
143
  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)
144
+ next if config[:ignoretype]&.include?(line.mount_type)
145
+ next if config[:ignoremnt]&.include?(line.mount_point)
146
+ next if config[:ignorepathre]&.match(line.mount_point)
147
+ next if config[:ignoreopt]&.include?(line.options)
148
+ next if config[:ignorereadonly] && line.options.split(',').include?('ro')
133
149
  next if config[:includemnt] && !config[:includemnt].include?(line.mount_point)
134
150
  rescue StandardError
135
151
  unknown 'An error occured getting the mount info'
@@ -157,6 +173,7 @@ class CheckDisk < Sensu::Plugin::Check::CLI
157
173
  if line.mount_type == 'devfs'
158
174
  return
159
175
  end
176
+
160
177
  if fs_info.respond_to?(:inodes) && !fs_info.inodes.nil? # needed for windows
161
178
  percent_i = percent_inodes(fs_info)
162
179
  if percent_i >= config[:icrit]
@@ -185,9 +202,18 @@ class CheckDisk < Sensu::Plugin::Check::CLI
185
202
  end
186
203
  end
187
204
 
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))
205
+ def to_human(size)
206
+ unit = [
207
+ [1_099_511_627_776, 'TiB'],
208
+ [1_073_741_824, 'GiB'],
209
+ [1_048_576, 'MiB'],
210
+ [1024, 'KiB'],
211
+ [0, 'B']
212
+ ].detect { |u| size >= u[0] }
213
+ format(
214
+ "%.2f #{unit[1]}",
215
+ (size >= 1024 ? size.to_f / unit[0] : size)
216
+ )
191
217
  end
192
218
 
193
219
  # Determine the percent inode usage
@@ -199,7 +225,17 @@ class CheckDisk < Sensu::Plugin::Check::CLI
199
225
  # Determine the percent byte usage
200
226
  #
201
227
  def percent_bytes(fs_info)
202
- (100.0 - (100.0 * fs_info.bytes_free / fs_info.bytes_total)).round(2)
228
+ if config[:ignore_reserved]
229
+ u100 = fs_info.bytes_used * 100.0
230
+ nonroot_total = fs_info.bytes_used + fs_info.bytes_available
231
+ if nonroot_total.zero?
232
+ 0
233
+ else
234
+ (u100 / nonroot_total + (u100 % nonroot_total != 0 ? 1 : 0)).round(2)
235
+ end
236
+ else
237
+ (100.0 - (100.0 * fs_info.bytes_free / fs_info.bytes_total)).round(2)
238
+ end
203
239
  end
204
240
 
205
241
  # Generate output
@@ -1,4 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
+ # frozen_string_literal: false
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(device)
57
+ if device.start_with?('UUID=')
58
+ uuid = device.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 device.start_with?('LABEL=')
66
+ label = device.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 device.start_with?('/dev/mapper')
74
+ if File.symlink?(device)
75
+ device = File.realpath(device, '/')
74
76
  end
75
77
  end
76
78
 
77
- d
79
+ device
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: false
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: false
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: false
3
+
2
4
  #
3
5
  # check-smart
4
6
  #
@@ -1,4 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
+ # frozen_string_literal: false
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: false
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: false
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 = 4
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.4
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-11-06 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
@@ -219,8 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  - !ruby/object:Gem::Version
220
220
  version: '0'
221
221
  requirements: []
222
- rubyforge_project:
223
- rubygems_version: 2.7.7
222
+ rubygems_version: 3.0.8
224
223
  signing_key:
225
224
  specification_version: 4
226
225
  summary: Sensu plugins for disk checks