sensu-plugins-disk-checks 2.4.2 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -1
- data/bin/check-smart.rb +29 -11
- data/lib/sensu-plugins-disk-checks/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e2270b4f0e3f5a79f427d625af1c3bc5bc08e0e
|
4
|
+
data.tar.gz: 2093789afcdb4cdea74ae511a8cbc3f206d0d62c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f44ad37fc75fa5cd63db38d76e8765495b751e315b41add5721dc70574f90ab4aae86142829c855066c73881c14fc052a4fd0fce8f55ec04d274480d586c2fd
|
7
|
+
data.tar.gz: 8aec7d6c80cf117ece7a9a41d4c96e7389d2a943b6dce88f80d55bb31c18d98be37356584af64f047da9c9b3009e7b7852cbef2883d32d16187b603a88b4d624
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,17 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [2.5.0] - 2017-08-28
|
9
|
+
### Changed
|
10
|
+
- check-smart.rb: The JSON file is now does not need to exist (@ChrisPortman)
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- check-smart.rb: Add support for legacy smartctl output relating to `Available` and `Enabled` (@ChrisPortman)
|
14
|
+
- check-smart.rb: Add option to specify the exit code to use when there are no smart capable devices (@ChrisPortman)
|
15
|
+
|
16
|
+
### Removed
|
17
|
+
- check-smart.rb: Removed duplicated smartctl runs
|
18
|
+
|
8
19
|
## [2.4.2] - 2017-08-17
|
9
20
|
### Fixed
|
10
21
|
- check-smart-status.rb: fixed regex for `Available` and `Enabled` (@nagyt234)
|
@@ -145,7 +156,8 @@ https://mathias-kettner.de/checkmk_filesystems.html
|
|
145
156
|
### Added
|
146
157
|
- initial release
|
147
158
|
|
148
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/2.
|
159
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/2.5.0...HEAD
|
160
|
+
[2.5.0]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/2.4.2...2.5.0
|
149
161
|
[2.4.2]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/2.4.1...2.4.2
|
150
162
|
[2.4.1]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/2.4.0...2.4.1
|
151
163
|
[2.4.0]: https://github.com/sensu-plugins/sensu-plugins-disk-checks/compare/2.3.0...2.4.0
|
data/bin/check-smart.rb
CHANGED
@@ -78,8 +78,17 @@ class Disk
|
|
78
78
|
#
|
79
79
|
def check_smart_capability!
|
80
80
|
output = `sudo #{@smart_binary} -i #{device_path}`
|
81
|
+
|
82
|
+
# Newer smartctl
|
81
83
|
@smart_available = !output.scan(/SMART support is:\s+Available/).empty?
|
82
84
|
@smart_enabled = !output.scan(/SMART support is:\s+Enabled/).empty?
|
85
|
+
|
86
|
+
unless smart_capable?
|
87
|
+
# Older smartctl
|
88
|
+
@smart_available = !output.scan(/Device supports SMART/).empty?
|
89
|
+
@smart_enabled = !output.scan(/and is Enabled/).empty?
|
90
|
+
end
|
91
|
+
|
83
92
|
@capability_output = output
|
84
93
|
end
|
85
94
|
|
@@ -98,9 +107,17 @@ end
|
|
98
107
|
class CheckSMART < Sensu::Plugin::Check::CLI
|
99
108
|
option :smart_incapable_disks,
|
100
109
|
long: '--smart-incapable-disks EXIT_CODE',
|
101
|
-
description: 'Exit code when SMART is unavailable/disabled on a disk
|
110
|
+
description: 'Exit code when SMART is unavailable/disabled on a disk',
|
102
111
|
proc: proc(&:to_sym),
|
103
|
-
default: :unknown
|
112
|
+
default: :unknown,
|
113
|
+
in: %i(unknown ok warn critical)
|
114
|
+
|
115
|
+
option :no_smart_capable_disks,
|
116
|
+
long: '--no-smart-capable-disks EXIT_CODE',
|
117
|
+
description: 'Exit code when there are no SMART capable disks',
|
118
|
+
proc: proc(&:to_sym),
|
119
|
+
default: :unknown,
|
120
|
+
in: %i(unknown ok warn critical)
|
104
121
|
|
105
122
|
option :binary,
|
106
123
|
short: '-b path/to/smartctl',
|
@@ -123,7 +140,11 @@ class CheckSMART < Sensu::Plugin::Check::CLI
|
|
123
140
|
@devices = []
|
124
141
|
|
125
142
|
# Load in the device configuration
|
126
|
-
@hardware =
|
143
|
+
@hardware = if File.readable?(config[:json])
|
144
|
+
JSON.parse(IO.read(config[:json]), symbolize_names: true)[:hardware][:devices]
|
145
|
+
else
|
146
|
+
{}
|
147
|
+
end
|
127
148
|
|
128
149
|
scan_disks!
|
129
150
|
end
|
@@ -141,13 +162,7 @@ class CheckSMART < Sensu::Plugin::Check::CLI
|
|
141
162
|
|
142
163
|
device = Disk.new(name, override, config[:binary])
|
143
164
|
|
144
|
-
|
145
|
-
|
146
|
-
# Check if we can use this device or not
|
147
|
-
available = !output.scan(/SMART support is:\s+Available/).empty?
|
148
|
-
enabled = !output.scan(/SMART support is:\s+Enabled/).empty?
|
149
|
-
|
150
|
-
@devices << device if available && enabled
|
165
|
+
@devices << device if device.smart_capable?
|
151
166
|
end
|
152
167
|
end
|
153
168
|
end
|
@@ -155,7 +170,10 @@ class CheckSMART < Sensu::Plugin::Check::CLI
|
|
155
170
|
# Main function
|
156
171
|
#
|
157
172
|
def run
|
158
|
-
|
173
|
+
exit_with(
|
174
|
+
config[:no_smart_capable_disks],
|
175
|
+
'No SMART capable devices found'
|
176
|
+
) unless @devices.length > 0
|
159
177
|
|
160
178
|
unhealthy_disks = @devices.select { |disk| disk.smart_capable? && !disk.healthy? }
|
161
179
|
unknown_disks = @devices.reject(&:smart_capable?)
|
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: 2.
|
4
|
+
version: 2.5.0
|
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-08-
|
11
|
+
date: 2017-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|