sensu-plugins-lvm 1.0.0 → 1.0.1

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
- SHA1:
3
- metadata.gz: bafedab39b4390863ae90f422b4a86d3d8aa172f
4
- data.tar.gz: a64692f0bdc68620ed98c1c140b625f15d4d98a2
2
+ SHA256:
3
+ metadata.gz: e9655a6231ee5e15854cef010f678fc75a22a1f27a29367f0db6c4eb9a37f513
4
+ data.tar.gz: 03e2f8852f9372abab489de6f1aa03079b9e7133d2647b4b3a0722a055d13ce8
5
5
  SHA512:
6
- metadata.gz: 234e7ac42f1745ae6290a3e588a8cb4bda22e6af002496af1cc6ca469eb73a7a90ad5ded2cec285eb026d7cba79483f5c00a155df7b4f707494b7fed98980cea
7
- data.tar.gz: 1db3c9a7d282196540b8e6ef04a9e20197543329acfc1fb2a1cba988a5ee931d7517a4d9f41f2d6f0a3988ac301bae8ca4e4c61fe0273c6544a91b0780091b5f
6
+ metadata.gz: a5d5d21db1b39e7eb6a308b2645e640b404cba51d608f9b292eddd5452a5bf49ae03517e7fe97503420140005a846029078c9894bc80cd7520fb88dcdecdc8e6
7
+ data.tar.gz: 5ae95c7c7f265f567844d9921e530e12b7ed685b1263e44e0bd19f4018a74ba35a36c4d1d04a65589a9be1c7a891d7e3448f213e12e2b8476d770c304dbd93cc
data/CHANGELOG.md CHANGED
@@ -1,10 +1,17 @@
1
- #Change Log
1
+ # Change Log
2
2
  This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
4
  This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [1.0.1] - 2018-07-06
9
+ ### Fixed
10
+ - check-lv-usage.rb: emit an `unknown` with a useful message rather than a false `ok` when no volumes are found (@sys-ops)
11
+
12
+ ### Changed
13
+ - general readability improvements and appeasing the cops (@majormoses)
14
+
8
15
  ## [1.0.0] - 2017-07-12
9
16
  ### Added
10
17
  - ruby 2.4 testing (@majormoses)
@@ -30,6 +37,7 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
30
37
  - Initial release
31
38
 
32
39
  [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-lvm/compare/1.0.0...HEAD
40
+ [1.0.1]: https://github.com/sensu-plugins/sensu-plugins-lvm/compare/1.0.0...1.0.1
33
41
  [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-lvm/compare/0.0.4...1.0.0
34
42
  [0.0.4]: https://github.com/sensu-plugins/sensu-plugins-lvm/compare/0.0.3...0.0.4
35
43
  [0.0.3]: https://github.com/sensu-plugins/sensu-plugins-lvm/compare/0.0.2...0.0.3
@@ -79,33 +79,44 @@ class CheckLVUsage < Sensu::Plugin::Check::CLI
79
79
  end
80
80
 
81
81
  def logical_volumes
82
- @lv ||= LVM::LVM.new.logical_volumes.list
82
+ @logical_volumes ||= LVM::LVM.new.logical_volumes.list
83
+ end
84
+
85
+ def empty_volumes_msg
86
+ # NOTE: when we drop ruby < 2.3 support switch to <<~ and indent sanely
87
+ string = <<-HEREDOC
88
+ An error occured getting the LVM info: got empty list of volumes.
89
+ Check to ensure sensu has been configured with appropriate permissions.
90
+ On linux systems it will generally need to allow executing
91
+ HEREDOC
92
+ string.squeeze(' ')
83
93
  end
84
94
 
85
95
  def filter_volumes(list)
96
+ unknown empty_volumes_msg if list.empty?
86
97
  begin
87
98
  return list.select { |l| config[:lv].include?(l.name) } if config[:lv]
88
99
  return list.select { |l| config[:full_name].include?(l.full_name) } if config[:full_name]
89
- rescue
100
+ rescue StandardError
90
101
  unknown 'An error occured getting the LVM info'
91
102
  end
92
103
  list
93
104
  end
94
105
 
95
- def check_usage(v)
96
- d_percent = v.data_percent.to_i
97
- m_percent = v.metadata_percent.to_i
106
+ def check_usage(volume)
107
+ d_percent = volume.data_percent.to_i
108
+ m_percent = volume.metadata_percent.to_i
98
109
 
99
110
  if d_percent >= config[:dcrit]
100
- @crit_lv << "#{v.full_name} data volume is #{d_percent}% used"
111
+ @crit_lv << "#{volume.full_name} data volume is #{d_percent}% used"
101
112
  elsif d_percent >= config[:dwarn]
102
- @warn_lv << "#{v.full_name} data volume is #{d_percent}% used"
113
+ @warn_lv << "#{volume.full_name} data volume is #{d_percent}% used"
103
114
  end
104
115
 
105
116
  if m_percent >= config[:mcrit]
106
- @crit_lv << "#{v.full_name} metadata volume is #{m_percent}% used"
117
+ @crit_lv << "#{volume.full_name} metadata volume is #{m_percent}% used"
107
118
  elsif m_percent >= config[:mwarn]
108
- @warn_lv << "#{v.full_name} metadata volume is #{m_percent}% used"
119
+ @warn_lv << "#{volume.full_name} metadata volume is #{m_percent}% used"
109
120
  end
110
121
  end
111
122
 
@@ -119,7 +130,7 @@ class CheckLVUsage < Sensu::Plugin::Check::CLI
119
130
  #
120
131
  def run
121
132
  volumes = filter_volumes(logical_volumes)
122
- volumes.each { |v| check_usage(v) }
133
+ volumes.each { |volume| check_usage(volume) }
123
134
  critical check_output unless @crit_lv.empty?
124
135
  warning check_output unless @warn_lv.empty?
125
136
  ok "All logical volume data usage under #{config[:dwarn]}% and metadata usage under #{config[:mwarn]}%"
@@ -75,7 +75,7 @@ class CheckVg < Sensu::Plugin::Check::CLI
75
75
  next if config[:ignorevg] && config[:ignorevg].include?(line.name)
76
76
  next if config[:ignorevgre] && config[:ignorevgre].match(line.name)
77
77
  next if config[:includevg] && !config[:includevg].include?(line.name)
78
- rescue
78
+ rescue StandardError
79
79
  unknown 'An error occured getting the LVM info'
80
80
  end
81
81
  check_volume_group(line)
@@ -99,9 +99,19 @@ class CheckVg < Sensu::Plugin::Check::CLI
99
99
  end
100
100
  end
101
101
 
102
- def to_human(s)
103
- 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] }
104
- "#{s > 0 ? s / unit[0] : s} #{unit[1]}"
102
+ def to_human(bytes)
103
+ units = [
104
+ [1_099_511_627_776, 'TiB'],
105
+ [1_073_741_824, 'GiB'],
106
+ [1_048_576, 'MiB'],
107
+ [1024, 'KiB'],
108
+ [0, 'B']
109
+ ].detect { |unit| bytes >= unit[0] }
110
+ if bytes > 0
111
+ bytes / units[0]
112
+ else
113
+ units[1]
114
+ end
105
115
  end
106
116
 
107
117
  # Generate output
@@ -1,6 +1,4 @@
1
1
  #! /usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
2
  #
5
3
  # metrics-vg-usage
6
4
  #
@@ -64,7 +62,7 @@ class VgUsageMetrics < Sensu::Plugin::Metric::CLI::Graphite
64
62
  next if config[:ignorevg] && config[:ignorevg].include?(line.name)
65
63
  next if config[:ignorevgre] && config[:ignorevgre].match(line.name)
66
64
  next if config[:includevg] && !config[:includevg].include?(line.name)
67
- rescue
65
+ rescue StandardError
68
66
  unknown 'An error occured getting the LVM info'
69
67
  end
70
68
  volume_group_metrics(line)
@@ -2,7 +2,7 @@ module SensuPluginsLvm
2
2
  module Version
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- PATCH = 0
5
+ PATCH = 1
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-lvm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
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: 2017-07-13 00:00:00.000000000 Z
11
+ date: 2018-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
221
  version: '0'
222
222
  requirements: []
223
223
  rubyforge_project:
224
- rubygems_version: 2.4.5
224
+ rubygems_version: 2.7.7
225
225
  signing_key:
226
226
  specification_version: 4
227
227
  summary: Sensu plugins for lvm