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 +5 -5
- data/CHANGELOG.md +9 -1
- data/bin/check-lv-usage.rb +21 -10
- data/bin/check-vg-usage.rb +14 -4
- data/bin/metrics-vg-usage.rb +1 -3
- data/lib/sensu-plugins-lvm/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e9655a6231ee5e15854cef010f678fc75a22a1f27a29367f0db6c4eb9a37f513
|
4
|
+
data.tar.gz: 03e2f8852f9372abab489de6f1aa03079b9e7133d2647b4b3a0722a055d13ce8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/bin/check-lv-usage.rb
CHANGED
@@ -79,33 +79,44 @@ class CheckLVUsage < Sensu::Plugin::Check::CLI
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def logical_volumes
|
82
|
-
@
|
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(
|
96
|
-
d_percent =
|
97
|
-
m_percent =
|
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 << "#{
|
111
|
+
@crit_lv << "#{volume.full_name} data volume is #{d_percent}% used"
|
101
112
|
elsif d_percent >= config[:dwarn]
|
102
|
-
@warn_lv << "#{
|
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 << "#{
|
117
|
+
@crit_lv << "#{volume.full_name} metadata volume is #{m_percent}% used"
|
107
118
|
elsif m_percent >= config[:mwarn]
|
108
|
-
@warn_lv << "#{
|
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 { |
|
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]}%"
|
data/bin/check-vg-usage.rb
CHANGED
@@ -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(
|
103
|
-
|
104
|
-
|
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
|
data/bin/metrics-vg-usage.rb
CHANGED
@@ -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)
|
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.
|
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:
|
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.
|
224
|
+
rubygems_version: 2.7.7
|
225
225
|
signing_key:
|
226
226
|
specification_version: 4
|
227
227
|
summary: Sensu plugins for lvm
|