sensu-plugins-lvm 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 50bea72bcf625fd4ac02865ca46368f32c9f98a6
4
+ data.tar.gz: 6d2050185419a3269221c085005a6092c1236e72
5
+ SHA512:
6
+ metadata.gz: f9befeb23dd98a58b5e51ff34eba30c4e28f180aef76efa14139fd68dc558d90899544602724e12322003e3c9dd0e5c9b8ad4f28cc84816388b80434d241fb91
7
+ data.tar.gz: a787507c4658829c66858cc5ef227cb218e0f7213a915d4c77480547312af54e6ea4e0d7f361e16469ef316cc62f044b33de4d26ad7c8a1dc07d178c5d584b7d
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ #Change Log
2
+ This project adheres to [Semantic Versioning](http://semver.org/).
3
+
4
+ ## 0.0.1 - 2016-04-12
5
+ ### Added
6
+ - Initial release
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Sensu-Plugins
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ ## sensu-plugins-lvm
2
+
3
+ [![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-lvm.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-lvm)
4
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-lvm.svg)](http://badge.fury.io/rb/sensu-plugins-lvm)
5
+ [![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-lvm/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-lvm)
6
+ [![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-lvm/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-lvm)
7
+ [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-lvm.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-lvm)
8
+
9
+ ## Functionality
10
+
11
+ **check-vg-usage**
12
+
13
+ Check volume group capacity based upon the gem do-ruby-lvm.
14
+
15
+ **metrics-vg-usage**
16
+
17
+ Output graphite metrics for volume group capacity and usage based upon the gem do-ruby-lvm.
18
+
19
+ ## Files
20
+ * bin/check-vg-usage.rb
21
+ * bin/metrics-vg-usage.rb
22
+
23
+ ## Installation
24
+
25
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
@@ -0,0 +1,121 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-vg-usage
4
+ #
5
+ # DESCRIPTION:
6
+ # Uses the di-ruby-lvm gem to get LVM volume group status
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
+ #
20
+ # NOTES:
21
+ #
22
+ # LICENSE:
23
+ # Copyright 2016 Aaron Brady <aaron@insom.me.uk>
24
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
25
+ # for details.
26
+ #
27
+
28
+ require 'sensu-plugin/check/cli'
29
+ require 'lvm'
30
+
31
+ #
32
+ # Check VG Usage
33
+ #
34
+ class CheckVg < Sensu::Plugin::Check::CLI
35
+ option :ignorevg,
36
+ short: '-i VG[,VG]',
37
+ description: 'Ignore volume group(s)',
38
+ proc: proc { |a| a.split(',') }
39
+
40
+ option :includevg,
41
+ description: 'Include only volume group(s)',
42
+ short: '-I VG[,VG]',
43
+ proc: proc { |a| a.split(',') }
44
+
45
+ option :ignorevgre,
46
+ short: '-p VG',
47
+ description: 'Ignore volume group(s) matching regular expression',
48
+ proc: proc { |a| Regexp.new(a) }
49
+
50
+ option :bwarn,
51
+ short: '-w PERCENT',
52
+ description: 'Warn if PERCENT or more of volume group full',
53
+ proc: proc(&:to_i),
54
+ default: 85
55
+
56
+ option :bcrit,
57
+ short: '-c PERCENT',
58
+ description: 'Critical if PERCENT or more of volume group full',
59
+ proc: proc(&:to_i),
60
+ default: 95
61
+
62
+ # Setup variables
63
+ #
64
+ def initialize
65
+ super
66
+ @crit_vg = []
67
+ @warn_vg = []
68
+ end
69
+
70
+ # Get group data
71
+ #
72
+ def volume_groups
73
+ LVM::LVM.new.volume_groups.each do |line|
74
+ begin
75
+ next if config[:ignorevg] && config[:ignorevg].include?(line.name)
76
+ next if config[:ignorevgre] && config[:ignorevgre].match(line.name)
77
+ next if config[:includevg] && !config[:includevg].include?(line.name)
78
+ rescue
79
+ unknown 'An error occured getting the LVM info'
80
+ end
81
+ check_volume_group(line)
82
+ end
83
+ end
84
+
85
+ def check_volume_group(line)
86
+ used_b = line.size - line.free
87
+ percent_b = ((used_b * 100) / line.size).round(2)
88
+
89
+ bcrit = config[:bcrit]
90
+ bwarn = config[:bwarn]
91
+
92
+ used = to_human(used_b)
93
+ total = to_human(line.size)
94
+
95
+ if percent_b >= bcrit
96
+ @crit_vg << "#{line.name} #{percent_b}% bytes usage (#{used}/#{total})"
97
+ elsif percent_b >= bwarn
98
+ @warn_vg << "#{line.name} #{percent_b}% bytes usage (#{used}/#{total})"
99
+ end
100
+ end
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]}"
105
+ end
106
+
107
+ # Generate output
108
+ #
109
+ def check_output
110
+ (@crit_vg + @warn_vg).join(', ')
111
+ end
112
+
113
+ # Main function
114
+ #
115
+ def run
116
+ volume_groups
117
+ critical check_output unless @crit_vg.empty?
118
+ warning check_output unless @warn_vg.empty?
119
+ ok "All volume group usage under #{config[:bwarn]}%"
120
+ end
121
+ end
@@ -0,0 +1,88 @@
1
+ #! /usr/bin/env ruby
2
+ # encoding: UTF-8
3
+ #
4
+ # metrics-vg-usage
5
+ #
6
+ # DESCRIPTION:
7
+ # Uses the di-ruby-lvm gem to get LVM volume group statistics
8
+ #
9
+ # OUTPUT:
10
+ # metric data
11
+ #
12
+ # PLATFORMS:
13
+ # Linux
14
+ #
15
+ # DEPENDENCIES:
16
+ # gem: sensu-plugin
17
+ # gem: di-ruby-lvm
18
+ #
19
+ # USAGE:
20
+ #
21
+ # NOTES:
22
+ #
23
+ # LICENSE:
24
+ # Copyright 2016 Aaron Brady <aaron@insom.me.uk>
25
+ # Copyright 2012 Sonian, Inc <chefs@sonian.net>
26
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
27
+ # for details.
28
+ #
29
+
30
+ require 'sensu-plugin/metric/cli'
31
+ require 'socket'
32
+ require 'lvm'
33
+
34
+ #
35
+ # VG Usage Metrics
36
+ #
37
+ class VgUsageMetrics < Sensu::Plugin::Metric::CLI::Graphite
38
+ option :scheme,
39
+ description: 'Metric naming scheme, text to prepend to .$parent.$child',
40
+ long: '--scheme SCHEME',
41
+ default: "#{Socket.gethostname}.vg_usage"
42
+
43
+ option :ignorevg,
44
+ short: '-i VG[,VG]',
45
+ description: 'Ignore volume group(s)',
46
+ proc: proc { |a| a.split(',') }
47
+
48
+ option :includevg,
49
+ description: 'Include only volume group(s)',
50
+ short: '-I VG[,VG]',
51
+ proc: proc { |a| a.split(',') }
52
+
53
+ option :ignorevgre,
54
+ short: '-p VG',
55
+ description: 'Ignore volume group(s) matching regular expression',
56
+ proc: proc { |a| Regexp.new(a) }
57
+
58
+ # Get group data
59
+ #
60
+ def volume_groups
61
+ LVM::LVM.new.volume_groups.each do |line|
62
+ begin
63
+ next if config[:ignorevg] && config[:ignorevg].include?(line.name)
64
+ next if config[:ignorevgre] && config[:ignorevgre].match(line.name)
65
+ next if config[:includevg] && !config[:includevg].include?(line.name)
66
+ rescue
67
+ unknown 'An error occured getting the LVM info'
68
+ end
69
+ volume_group_metrics(line)
70
+ end
71
+ end
72
+
73
+ def volume_group_metrics(line)
74
+ used_b = line.size - line.free
75
+ percent_b = ((used_b * 100) / line.size).round(2)
76
+
77
+ output [config[:scheme], line.name, 'used'].join('.'), used_b
78
+ output [config[:scheme], line.name, 'avail'].join('.'), line.free
79
+ output [config[:scheme], line.name, 'used_percentage'].join('.'), percent_b
80
+ end
81
+
82
+ # Main function
83
+ #
84
+ def run
85
+ volume_groups
86
+ ok
87
+ end
88
+ end
@@ -0,0 +1,9 @@
1
+ module SensuPluginsLvm
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ PATCH = 1
6
+
7
+ VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
+ end
9
+ end
@@ -0,0 +1 @@
1
+ require 'sensu-plugins-lvm/version'
metadata ADDED
@@ -0,0 +1,212 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-lvm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sensu-Plugins and contributors
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sensu-plugin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: di-ruby-lvm
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: codeclimate-test-reporter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: github-markup
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.10'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.10'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '10.5'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '10.5'
111
+ - !ruby/object:Gem::Dependency
112
+ name: redcarpet
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.2'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.2'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.37'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.37'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '3.4'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.4'
153
+ - !ruby/object:Gem::Dependency
154
+ name: yard
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.8'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.8'
167
+ description: Sensu plugins for LVM
168
+ email: "<sensu-users@googlegroups.com>"
169
+ executables:
170
+ - metrics-vg-usage.rb
171
+ - check-vg-usage.rb
172
+ extensions: []
173
+ extra_rdoc_files: []
174
+ files:
175
+ - CHANGELOG.md
176
+ - LICENSE
177
+ - README.md
178
+ - bin/check-vg-usage.rb
179
+ - bin/metrics-vg-usage.rb
180
+ - lib/sensu-plugins-lvm.rb
181
+ - lib/sensu-plugins-lvm/version.rb
182
+ homepage: https://github.com/sensu-plugins/sensu-plugins-lvm
183
+ licenses:
184
+ - MIT
185
+ metadata:
186
+ maintainer: sensu-plugin
187
+ development_status: active
188
+ production_status: unstable - testing recommended
189
+ release_draft: 'false'
190
+ release_prerelease: 'false'
191
+ post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
192
+ in /etc/default/sensu
193
+ rdoc_options: []
194
+ require_paths:
195
+ - lib
196
+ required_ruby_version: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: 2.0.0
201
+ required_rubygems_version: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - ">="
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ requirements: []
207
+ rubyforge_project:
208
+ rubygems_version: 2.4.5.1
209
+ signing_key:
210
+ specification_version: 4
211
+ summary: Sensu plugins for lvm
212
+ test_files: []