sensu-plugins-zfs 0.3.3 → 0.4.0
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 +4 -4
- data/bin/check-zpool.rb +18 -0
- data/lib/sensu-plugins-zfs/version.rb +1 -1
- data/lib/sensu-plugins-zfs/zpool.rb +33 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15bc681d790d66bbc7afae490801a3a75e6cc07b
|
4
|
+
data.tar.gz: f81c01212727845a3b7ee578f86722fe45f01918
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f56f6571570303705201c833500d86b7af9826d6aa0fc04f019346c081bda6fd0c42b3148e64d46f614babdb54d88314e63715daf59948dd4236ffb189d4528
|
7
|
+
data.tar.gz: 8afeaab356b5c1a8bc7d2576cc737151e9783c069038a6acabef6b9334464b7305c8dc1b3e2c93421455e3c37130b18eee7cf58272f3d0851101f6b0742144db
|
data/bin/check-zpool.rb
CHANGED
@@ -7,10 +7,28 @@ class CheckZPool < Sensu::Plugin::Check::CLI
|
|
7
7
|
def run
|
8
8
|
zpools = SensuPluginsZFS::ZFS.zpools
|
9
9
|
zpools.each do |zp|
|
10
|
+
check_state zp
|
11
|
+
check_vdevs zp
|
10
12
|
unless zp.ok?
|
11
13
|
critical "zpool #{zp.name} has state #{zp.state}"
|
12
14
|
end
|
13
15
|
end
|
14
16
|
ok "all zpools are ok"
|
15
17
|
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def check_state(zp)
|
22
|
+
unless zp.ok?
|
23
|
+
critical "zpool #{zp.name} has state #{zp.state}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def check_vdevs(zp)
|
28
|
+
zp.vdevs.each do |vd|
|
29
|
+
unless vd.ok?
|
30
|
+
warning "vdev #{vd.name} of zpool #{vd.zpool.name} has errors"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
16
34
|
end
|
@@ -1,24 +1,53 @@
|
|
1
1
|
module SensuPluginsZFS
|
2
2
|
class ZFS
|
3
3
|
def self.zpools
|
4
|
-
|
5
|
-
|
6
|
-
res << ZPool.new(name.strip)
|
4
|
+
%x[sudo zpool list -H -o name].lines('').map do |l|
|
5
|
+
ZPool.new(l.strip)
|
7
6
|
end
|
8
7
|
res
|
9
8
|
end
|
10
9
|
end
|
11
10
|
|
12
11
|
class ZPool
|
13
|
-
attr_reader :state, :name
|
12
|
+
attr_reader :state, :name, :vdevs
|
14
13
|
|
15
14
|
def initialize(name)
|
16
15
|
@name = name
|
17
16
|
@state = %x[sudo zpool status #{name} | grep '^ state: ' | cut -d ' ' -f 3].strip
|
17
|
+
@vdevs = create_vdevs
|
18
18
|
end
|
19
19
|
|
20
20
|
def ok?
|
21
21
|
return @state == "ONLINE"
|
22
22
|
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def create_vdevs
|
27
|
+
cmd_out = %x[sudo zpool status #{@name} | grep ONLINE | grep -v state | awk '{print $1 " " $2 " " $3 " " $4 " " $5}']
|
28
|
+
cmd_out.lines('').map do |l|
|
29
|
+
arr = l.strip.split(' ')
|
30
|
+
VDev.new(self, arr[0], arr[1], arr[2].to_i, arr[3].to_i, arr[4].to_i)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class VDev
|
36
|
+
attr_reader :zpool, :name, :read, :write, :chksum
|
37
|
+
def initialize(zpool, name, state, read, write, chksum)
|
38
|
+
@zpool = zpool
|
39
|
+
@state = state
|
40
|
+
@name = name
|
41
|
+
@read = read
|
42
|
+
@write = write
|
43
|
+
@chksum = chksum
|
44
|
+
end
|
45
|
+
|
46
|
+
def ok?
|
47
|
+
return @state =~ /(ONLINE|AVAIL)/ &&
|
48
|
+
@read == 0 &&
|
49
|
+
@write == 0 &&
|
50
|
+
@checksum == 0
|
51
|
+
end
|
23
52
|
end
|
24
53
|
end
|