sensu-plugins-lvm 0.0.1 → 0.0.2

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: 50bea72bcf625fd4ac02865ca46368f32c9f98a6
4
- data.tar.gz: 6d2050185419a3269221c085005a6092c1236e72
3
+ metadata.gz: a830ba2c64cd810d721e00bb75b2fd90987e346d
4
+ data.tar.gz: 480cb0bbd06026d6af1db36e8f56e9c23929d364
5
5
  SHA512:
6
- metadata.gz: f9befeb23dd98a58b5e51ff34eba30c4e28f180aef76efa14139fd68dc558d90899544602724e12322003e3c9dd0e5c9b8ad4f28cc84816388b80434d241fb91
7
- data.tar.gz: a787507c4658829c66858cc5ef227cb218e0f7213a915d4c77480547312af54e6ea4e0d7f361e16469ef316cc62f044b33de4d26ad7c8a1dc07d178c5d584b7d
6
+ metadata.gz: 9cc61995e8011ca59b06949d522e6fe69282b161c4b625d9fc0c57166e15725fd59f67a2b41f79b4fc33f357f323728f82d8723d4306228a7fa1d4cd52dc91a0
7
+ data.tar.gz: 4891d8349f4af79975b73bd51ed3c6a6a1ae0e171cb27ecfc53226768a783a0915aacfd4415e4673cefb017df1b75a513b6e322924187882248795a6e2c558b1
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  #Change Log
2
2
  This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
+ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
+
6
+ ## [Unreleased]
7
+ ### 0.0.2 - 2016-10-27
8
+ - check-lv-usage.rb: added
9
+
4
10
  ## 0.0.1 - 2016-04-12
5
11
  ### Added
6
12
  - Initial release
data/README.md CHANGED
@@ -8,6 +8,10 @@
8
8
 
9
9
  ## Functionality
10
10
 
11
+ **check-lv-usage**
12
+
13
+ Checks the usage on the logical volume. Checks both data and metadata volumes associated with Physical Volume
14
+
11
15
  **check-vg-usage**
12
16
 
13
17
  Check volume group capacity based upon the gem do-ruby-lvm.
@@ -16,7 +20,9 @@ Check volume group capacity based upon the gem do-ruby-lvm.
16
20
 
17
21
  Output graphite metrics for volume group capacity and usage based upon the gem do-ruby-lvm.
18
22
 
23
+
19
24
  ## Files
25
+ * bin/check-lv-usage.rb
20
26
  * bin/check-vg-usage.rb
21
27
  * bin/metrics-vg-usage.rb
22
28
 
@@ -0,0 +1,127 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-lv-usage
4
+ #
5
+ # DESCRIPTION:
6
+ # Uses the di-ruby-lvm gem to get the Data% from LVS command
7
+ #
8
+ # OUTPUT:
9
+ # plain text
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: sensu-plugin
16
+ # gem: di-ruby-lvm
17
+ #
18
+ # USAGE:
19
+ # ./check-lv-usage.rb
20
+ #
21
+ # NOTES:
22
+ #
23
+ # LICENSE:
24
+ # Copyright 2016 Zach Bintliff <zbintliff@gmail.com>
25
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
26
+ # for details.
27
+ #
28
+
29
+ require 'sensu-plugin/check/cli'
30
+ require 'lvm'
31
+
32
+ #
33
+ # Check Data and MetaData Usage on LV of LVM
34
+ #
35
+ class CheckLVUsage < Sensu::Plugin::Check::CLI
36
+ option :lv,
37
+ short: '-l LogicalVolume[,LogicalVolume]',
38
+ description: 'Name of logical volume (thinpool)',
39
+ proc: proc { |a| a.split(',') }
40
+
41
+ option :full_name,
42
+ short: '-f FullLogicalVolume[,FullLogicalVolume]',
43
+ description: 'Name of logical volume (docker/thinpool)',
44
+ proc: proc { |a| a.split(',') }
45
+
46
+ option :dwarn,
47
+ short: '-w PERCENT',
48
+ long: '--data-warn PERCENT',
49
+ description: 'Warn if PERCENT or more of logical data volume',
50
+ proc: proc(&:to_i),
51
+ default: 85
52
+
53
+ option :dcrit,
54
+ short: '-c PERCENT',
55
+ long: '--data-critical PERCENT',
56
+ description: 'Critical if PERCENT or more of logical data volume',
57
+ proc: proc(&:to_i),
58
+ default: 95
59
+
60
+ option :mwarn,
61
+ short: '-W PERCENT',
62
+ long: '--metadata-warn PERCENT',
63
+ description: 'Warn if PERCENT or more of logical metadata volume',
64
+ proc: proc(&:to_i),
65
+ default: 85
66
+
67
+ option :mcrit,
68
+ short: '-C PERCENT',
69
+ long: '--metadata-critical PERCENT',
70
+ description: 'Critical if PERCENT or more of logical metadata volume',
71
+ proc: proc(&:to_i),
72
+ default: 95
73
+ # Setup variables
74
+ #
75
+ def initialize(argv = ARGV)
76
+ super
77
+ @crit_lv = []
78
+ @warn_lv = []
79
+ end
80
+
81
+ def logical_volumes
82
+ @lv ||= LVM::LVM.new.logical_volumes.list
83
+ end
84
+
85
+ def filter_volumes(list)
86
+ begin
87
+ return list.select { |l| config[:lv].include?(l.name) } if config[:lv]
88
+ return list.select { |l| config[:full_name].include?(l.full_name) } if config[:full_name]
89
+ rescue
90
+ unknown 'An error occured getting the LVM info'
91
+ end
92
+ list
93
+ end
94
+
95
+ def check_usage(v)
96
+ d_percent = v.data_percent.to_i
97
+ m_percent = v.metadata_percent.to_i
98
+
99
+ if d_percent >= config[:dcrit]
100
+ @crit_lv << "#{v.full_name} data volume is #{d_percent}% used"
101
+ elsif d_percent >= config[:dwarn]
102
+ @warn_lv << "#{v.full_name} data volume is #{d_percent}% used"
103
+ end
104
+
105
+ if m_percent >= config[:mcrit]
106
+ @crit_lv << "#{v.full_name} metadata volume is #{m_percent}% used"
107
+ elsif m_percent >= config[:mwarn]
108
+ @warn_lv << "#{v.full_name} metadata volume is #{m_percent}% used"
109
+ end
110
+ end
111
+
112
+ # Generate output
113
+ #
114
+ def check_output
115
+ (@crit_lv + @warn_lv).join(', ')
116
+ end
117
+
118
+ # Main function
119
+ #
120
+ def run
121
+ volumes = filter_volumes(logical_volumes)
122
+ volumes.each { |v| check_usage(v) }
123
+ critical check_output unless @crit_lv.empty?
124
+ warning check_output unless @warn_lv.empty?
125
+ ok "All logical volume data usage under #{config[:dwarn]}% and metadata usage under #{config[:mwarn]}%"
126
+ end
127
+ end
@@ -2,7 +2,7 @@ module SensuPluginsLvm
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- PATCH = 1
5
+ PATCH = 2
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-lvm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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: 2016-04-12 00:00:00.000000000 Z
11
+ date: 2016-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.2'
27
27
  - !ruby/object:Gem::Dependency
@@ -42,143 +42,145 @@ dependencies:
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.7'
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
54
  version: '1.7'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: codeclimate-test-reporter
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0.4'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.4'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: github-markup
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: pry
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0.10'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.10'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ~>
102
102
  - !ruby/object:Gem::Version
103
103
  version: '10.5'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: '10.5'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: redcarpet
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ~>
116
116
  - !ruby/object:Gem::Version
117
117
  version: '3.2'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ~>
123
123
  - !ruby/object:Gem::Version
124
124
  version: '3.2'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rubocop
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - ~>
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0.37'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - ~>
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0.37'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rspec
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - "~>"
143
+ - - ~>
144
144
  - !ruby/object:Gem::Version
145
145
  version: '3.4'
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
152
  version: '3.4'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: yard
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - "~>"
157
+ - - ~>
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0.8'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - "~>"
164
+ - - ~>
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0.8'
167
167
  description: Sensu plugins for LVM
168
- email: "<sensu-users@googlegroups.com>"
168
+ email: <sensu-users@googlegroups.com>
169
169
  executables:
170
- - metrics-vg-usage.rb
170
+ - check-lv-usage.rb
171
171
  - check-vg-usage.rb
172
+ - metrics-vg-usage.rb
172
173
  extensions: []
173
174
  extra_rdoc_files: []
174
175
  files:
175
- - CHANGELOG.md
176
- - LICENSE
177
- - README.md
176
+ - bin/check-lv-usage.rb
178
177
  - bin/check-vg-usage.rb
179
178
  - bin/metrics-vg-usage.rb
180
- - lib/sensu-plugins-lvm.rb
181
179
  - lib/sensu-plugins-lvm/version.rb
180
+ - lib/sensu-plugins-lvm.rb
181
+ - LICENSE
182
+ - README.md
183
+ - CHANGELOG.md
182
184
  homepage: https://github.com/sensu-plugins/sensu-plugins-lvm
183
185
  licenses:
184
186
  - MIT
@@ -195,17 +197,17 @@ require_paths:
195
197
  - lib
196
198
  required_ruby_version: !ruby/object:Gem::Requirement
197
199
  requirements:
198
- - - ">="
200
+ - - '>='
199
201
  - !ruby/object:Gem::Version
200
202
  version: 2.0.0
201
203
  required_rubygems_version: !ruby/object:Gem::Requirement
202
204
  requirements:
203
- - - ">="
205
+ - - '>='
204
206
  - !ruby/object:Gem::Version
205
207
  version: '0'
206
208
  requirements: []
207
209
  rubyforge_project:
208
- rubygems_version: 2.4.5.1
210
+ rubygems_version: 2.0.14.1
209
211
  signing_key:
210
212
  specification_version: 4
211
213
  summary: Sensu plugins for lvm