sensu-plugins-zfs 1.2.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -0
- data/README.md +6 -2
- data/bin/check-zpool.rb +26 -22
- data/lib/sensu-plugins-zfs.rb +1 -1
- data/lib/sensu-plugins-zfs/version.rb +7 -1
- data/lib/sensu-plugins-zfs/zpool.rb +20 -21
- metadata +113 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be58d3fc1e0329cd050171f9042b7d59b962907f
|
4
|
+
data.tar.gz: e7c9bcbb0b31d44d42cbea045026a22ff7fcec18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ded2ed80ebc6b9ad85f81b6e3378627ec105505087da6b89d66c0dbb10c083d70ca97a14248c268663d74b9bceaed100c39b3ff0449fa65ce12566ea6bf243de
|
7
|
+
data.tar.gz: ce55792e7d806196ca8ce33918edbd3cbc06a91555432ddbf2b3b5501667ab013865bfe3199c52ca46d9fb3c42955266ac3bc1c2014514278e693d0b1426a3e6
|
data/LICENSE
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
3
|
Copyright (c) 2017 Benjamin Nørgaard
|
4
|
+
Copyright (c) 2017 Sensu Community Plugins
|
4
5
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
7
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
Sensu plugin for zfs health checks.
|
4
4
|
|
5
|
+
[![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-zfs.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-zfs)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/sensu-plugins-zfs.svg)](http://badge.fury.io/rb/sensu-plugins-zfs)
|
7
|
+
[![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-zfs.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-zfs)
|
8
|
+
[![Community Slack](https://slack.sensu.io/badge.svg)](https://slack.sensu.io/badge)
|
9
|
+
|
5
10
|
## Checks
|
6
11
|
|
7
12
|
### check-zpool.rb
|
@@ -35,10 +40,9 @@ I have a few ideas that would be nice:
|
|
35
40
|
- [x] Check that disks have been scrubbed recently
|
36
41
|
- [ ] Metric for disk utilization
|
37
42
|
|
38
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/sensu-plugins/sensu-plugins-zfs.
|
39
44
|
|
40
45
|
|
41
46
|
## License
|
42
47
|
|
43
48
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
44
|
-
|
data/bin/check-zpool.rb
CHANGED
@@ -5,29 +5,31 @@ require 'sensu-plugins-zfs'
|
|
5
5
|
|
6
6
|
class CheckZPool < Sensu::Plugin::Check::CLI
|
7
7
|
option :zpool,
|
8
|
-
short:
|
9
|
-
long:
|
10
|
-
description:
|
8
|
+
short: '-z ZPOOL',
|
9
|
+
long: '--zpool ZPOOL',
|
10
|
+
description: 'Name of zpool to check. If omitted, we check all zpools'
|
11
11
|
|
12
12
|
option :cap_warn,
|
13
|
-
short:
|
14
|
-
long:
|
15
|
-
description:
|
13
|
+
short: '-c PERCENTAGE',
|
14
|
+
long: '--capacity-warn PERCENTAGE',
|
15
|
+
description: 'Warn if capacity in percent is above this threshold',
|
16
16
|
default: 80
|
17
17
|
|
18
18
|
option :cap_crit,
|
19
|
-
short:
|
20
|
-
long:
|
21
|
-
description:
|
19
|
+
short: '-C PERCENTAGE',
|
20
|
+
long: '--capacity-crit PERCENTAGE',
|
21
|
+
description: 'Crit if capacity in percent is above this threshold',
|
22
22
|
default: 90
|
23
23
|
|
24
24
|
option :scrubbing_interval,
|
25
|
-
short:
|
26
|
-
long:
|
27
|
-
description:
|
25
|
+
short: '-s DAYS',
|
26
|
+
long: '--scrubbing-interval DAYS',
|
27
|
+
description: 'Warn it is more than this number of days since last scrub',
|
28
28
|
default: 7
|
29
29
|
|
30
30
|
def run
|
31
|
+
@warnings = []
|
32
|
+
@criticals = []
|
31
33
|
zpools = []
|
32
34
|
if config[:zpool]
|
33
35
|
zpools << SensuPluginsZFS::ZPool.new(config[:zpool])
|
@@ -36,44 +38,46 @@ class CheckZPool < Sensu::Plugin::Check::CLI
|
|
36
38
|
end
|
37
39
|
zpools.each do |zp|
|
38
40
|
check_state zp
|
39
|
-
check_vdevs zp
|
40
41
|
check_capacity zp
|
42
|
+
check_vdevs zp
|
41
43
|
check_recently_scrubbed zp
|
42
44
|
end
|
45
|
+
puts @criticals
|
46
|
+
puts @warnings
|
47
|
+
critical @criticals.join(', ') unless @criticals.empty?
|
48
|
+
warning @warnings.join(', ') unless @warnings.empty?
|
43
49
|
if config[:zpool]
|
44
50
|
ok "zpool #{config[:zpool]} is ok"
|
45
51
|
end
|
46
|
-
ok
|
52
|
+
ok 'all zpools are ok'
|
47
53
|
end
|
48
54
|
|
49
55
|
private
|
50
56
|
|
51
57
|
def check_state(zp)
|
52
|
-
unless zp.ok?
|
53
|
-
critical "zpool #{zp.name} has state #{zp.state}"
|
54
|
-
end
|
58
|
+
@criticals << "zpool #{zp.name} has state #{zp.state}" unless zp.ok?
|
55
59
|
end
|
56
60
|
|
57
61
|
def check_vdevs(zp)
|
58
62
|
zp.vdevs.each do |vd|
|
59
63
|
unless vd.ok?
|
60
|
-
|
64
|
+
@warnings << "vdev #{vd.name} of zpool #{vd.zpool.name} has errors"
|
61
65
|
end
|
62
66
|
end
|
63
67
|
end
|
64
68
|
|
65
69
|
def check_capacity(zp)
|
66
70
|
if zp.capacity > config[:cap_crit].to_i
|
67
|
-
|
71
|
+
@criticals << "capacity for zpool #{zp.name} is above #{config[:cap_crit]}% (currently #{zp.capacity}%)"
|
68
72
|
elsif zp.capacity > config[:cap_warn].to_i
|
69
|
-
|
73
|
+
@warnings << "capacity for zpool #{zp.name} is above #{config[:cap_warn]}% (currently #{zp.capacity}%)"
|
70
74
|
end
|
71
75
|
end
|
72
76
|
|
73
77
|
def check_recently_scrubbed(zp)
|
74
78
|
last_scrub = zp.scrubbed_at
|
75
|
-
if last_scrub < Time.now - 60 * 60 * 24 * config[:scrubbing_interval].to_i
|
76
|
-
|
79
|
+
if last_scrub < Time.now - 60 * 60 * 24 * config[:scrubbing_interval].to_i # rubocop:disable Style/GuardClause
|
80
|
+
@warnings << "It is more than #{config[:scrubbing_interval]} days since zpool #{zp.name} was scrubbed. Last scrubbed #{last_scrub}"
|
77
81
|
end
|
78
82
|
end
|
79
83
|
end
|
data/lib/sensu-plugins-zfs.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'sensu-plugins-zfs/zpool'
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require 'time'
|
2
2
|
|
3
3
|
module SensuPluginsZFS
|
4
4
|
class ZFS
|
5
5
|
def self.zpools
|
6
|
-
|
6
|
+
`sudo zpool list -H -o name`.lines.map do |l|
|
7
7
|
ZPool.new(l.strip)
|
8
8
|
end
|
9
9
|
end
|
@@ -14,46 +14,43 @@ module SensuPluginsZFS
|
|
14
14
|
|
15
15
|
def initialize(name)
|
16
16
|
@name = name
|
17
|
-
@state =
|
18
|
-
@capacity =
|
17
|
+
@state = `sudo zpool status #{name} | grep '^ state: ' | cut -d ' ' -f 3`.strip
|
18
|
+
@capacity = `sudo zpool get -H capacity #{@name} | awk '{print $3}' | cut -d '%' -f1`.strip.to_i
|
19
19
|
@vdevs = create_vdevs name
|
20
20
|
end
|
21
21
|
|
22
22
|
def ok?
|
23
|
-
@state ==
|
23
|
+
@state == 'ONLINE'
|
24
24
|
end
|
25
25
|
|
26
26
|
def scrubbed_at
|
27
|
-
if never_scrubbed?
|
28
|
-
|
29
|
-
|
30
|
-
return Time.now
|
31
|
-
end
|
32
|
-
Time.parse %x[sudo zpool status #{@name} | grep '^ scan: scrub' | awk '{print $11" "$12" "$13" "$14" "$15}'].strip
|
27
|
+
return Time.at(0) if never_scrubbed?
|
28
|
+
return Time.now if scrub_in_progress?
|
29
|
+
Time.parse `sudo zpool status #{@name} | grep '^ scan: scrub' | awk '{print $11" "$12" "$13" "$14" "$15}'`.strip # rubocop:disable
|
33
30
|
end
|
34
31
|
|
35
32
|
private
|
36
33
|
|
37
34
|
def create_vdevs(name)
|
38
|
-
cmd_out =
|
39
|
-
cmd_out.lines
|
35
|
+
cmd_out = `sudo zpool status #{name} | grep ONLINE | grep -v state | awk '{print $1 " " $2 " " $3 " " $4 " " $5}'`
|
36
|
+
cmd_out.lines.map do |l|
|
40
37
|
arr = l.strip.split(' ')
|
41
38
|
VDev.new(self, arr[0], arr[1], arr[2].to_i, arr[3].to_i, arr[4].to_i)
|
42
39
|
end
|
43
40
|
end
|
44
|
-
|
41
|
+
|
45
42
|
def never_scrubbed?
|
46
|
-
|
43
|
+
`sudo zpool status #{@name} | egrep -c "none requested"`.strip.to_i == 1
|
47
44
|
end
|
48
45
|
|
49
46
|
def scrub_in_progress?
|
50
|
-
|
47
|
+
`sudo zpool status #{@name} | egrep -c "scrub in progress|resilver"`.strip.to_i == 1
|
51
48
|
end
|
52
49
|
end
|
53
50
|
|
54
51
|
class VDev
|
55
52
|
attr_reader :zpool, :name, :read, :write, :chksum
|
56
|
-
def initialize(zpool, name, state, read, write, chksum)
|
53
|
+
def initialize(zpool, name, state, read, write, chksum) # rubocop:disable Metrics/ParameterLists
|
57
54
|
@zpool = zpool
|
58
55
|
@name = name
|
59
56
|
@state = state
|
@@ -63,10 +60,12 @@ module SensuPluginsZFS
|
|
63
60
|
end
|
64
61
|
|
65
62
|
def ok?
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
63
|
+
# TODO: I am not sure why this double negation exists and someone should
|
64
|
+
# come back in and fix this later.
|
65
|
+
!!(@state =~ /(ONLINE|AVAIL)/) && # rubocop:disable Style/DoubleNegation:
|
66
|
+
@read.zero? &&
|
67
|
+
@write.zero? &&
|
68
|
+
@chksum.zero?
|
70
69
|
end
|
71
70
|
end
|
72
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-zfs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Nørgaard
|
8
|
+
- Sensu-Plugins and contributors
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2018-02-27 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: sensu-plugin
|
@@ -38,9 +39,108 @@ dependencies:
|
|
38
39
|
- - "~>"
|
39
40
|
- !ruby/object:Gem::Version
|
40
41
|
version: '1.14'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: github-markup
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.3'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.3'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: pry
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.10'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.10'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rake
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '10.0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '10.0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: redcarpet
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '3.2'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '3.2'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rspec
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '3.1'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '3.1'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: rubocop
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 0.51.0
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 0.51.0
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: yard
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0.8'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0.8'
|
41
140
|
description: Sensu plugin for zfs
|
42
141
|
email:
|
43
142
|
- b@noergaard.dk
|
143
|
+
- "<sensu-users@googlegroups.com>"
|
44
144
|
executables:
|
45
145
|
- check-zpool.rb
|
46
146
|
extensions: []
|
@@ -52,11 +152,17 @@ files:
|
|
52
152
|
- lib/sensu-plugins-zfs.rb
|
53
153
|
- lib/sensu-plugins-zfs/version.rb
|
54
154
|
- lib/sensu-plugins-zfs/zpool.rb
|
55
|
-
homepage: https://github.com/
|
155
|
+
homepage: https://github.com/sensu-plugins/sensu-plugins-zfs
|
56
156
|
licenses:
|
57
157
|
- MIT
|
58
|
-
metadata:
|
59
|
-
|
158
|
+
metadata:
|
159
|
+
maintianer: sensu-plugin
|
160
|
+
development_status: active
|
161
|
+
production_status: unstable - testing recommended
|
162
|
+
release_draft: 'false'
|
163
|
+
release_prerelease: 'false'
|
164
|
+
post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
|
165
|
+
in /etc/default/sensu
|
60
166
|
rdoc_options: []
|
61
167
|
require_paths:
|
62
168
|
- lib
|
@@ -64,7 +170,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
170
|
requirements:
|
65
171
|
- - ">="
|
66
172
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
173
|
+
version: 2.1.0
|
68
174
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
175
|
requirements:
|
70
176
|
- - ">="
|
@@ -72,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
178
|
version: '0'
|
73
179
|
requirements: []
|
74
180
|
rubyforge_project:
|
75
|
-
rubygems_version: 2.
|
181
|
+
rubygems_version: 2.5.2.1
|
76
182
|
signing_key:
|
77
183
|
specification_version: 4
|
78
184
|
summary: Sensu plugin for zfs
|