sensu-plugins-zfs 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 183780cd78d850ca4df74099c6ab32d80adfa824
4
- data.tar.gz: e6c302360c0f34ad209e0fefb30f563ae5c068bc
3
+ metadata.gz: 9819878e1bc706d727fdb27a4f10ab04d36bea72
4
+ data.tar.gz: dcc0cf15963fab400f4b105d819b149bbc36d650
5
5
  SHA512:
6
- metadata.gz: db7d9d2caaba44d9cf2d85d5e30a8a321c2fe1d33df155c67fefa40a688383d866682e8ff644f0adb9692e8d053cbe5fca2802225824c836912989ea49e570b5
7
- data.tar.gz: b533ad3959a7ece387e7d15b8f61c0cb771411c35647cdf360e6419b2d9a06ea7f28d4d3dd7df6a4b7cf10ae5b0b19446721916fda3cc744a6e1e6552795cf8b
6
+ metadata.gz: 33cff7c92b5771efc2623422386722a66c13830ca0c500b9177d539f0adc4f537e914d4c5e6a8742b193863e14833e5418cd404bac7a073a941540048ad05007
7
+ data.tar.gz: d74a8dec3268d5ede33575824f25c586dfca6f78c1a982b5af876178f89d3795605300604aa26c5b704bb47bb4b99f16ce683b95d55da73759646bee68c9be5d
data/README.md CHANGED
@@ -10,6 +10,8 @@ Checks if the zpool state is ONLINE and wether there has been any errors on
10
10
  vdevs.
11
11
 
12
12
  - `-z, --zpool` What zpool to check. If omitted, we check all zpools.
13
+ - `-c, --capacity-warn` Capacity threshold for when to warn. (default 80)
14
+ - `-C, --capacity-crit` Capacity threshold for when to crit. (default 90)
13
15
 
14
16
  ## Installation
15
17
  [Installation and setup](http://sensu-plugins.io/docs/installation_instructions.html)
@@ -20,8 +22,11 @@ At this time ideas for additional checks/metrics would be very much appreciated.
20
22
 
21
23
  I have a few ideas that would be nice:
22
24
 
25
+ - [x] Check for zpool state
26
+ - [x] Check for vdev errors
27
+ - [x] Check for pool capacity
23
28
  - [ ] Check that disks have been scrubbed recently
24
- - [ ] Check/metric for pool capacity
29
+ - [ ] Metric for disk utilization
25
30
 
26
31
  Bug reports and pull requests are welcome on GitHub at https://github.com/blacksails/sensu-plugins-zfs.
27
32
 
data/bin/check-zpool.rb CHANGED
@@ -12,15 +12,21 @@ class CheckZPool < Sensu::Plugin::Check::CLI
12
12
  option :cap_warn,
13
13
  short: "-c PERCENTAGE",
14
14
  long: "--capacity-warn PERCENTAGE",
15
- description: "Warn if capacity is above this threshold",
15
+ description: "Warn if capacity in percent is above this threshold",
16
16
  default: 80
17
17
 
18
18
  option :cap_crit,
19
19
  short: "-C PERCENTAGE",
20
20
  long: "--capacity-crit PERCENTAGE",
21
- description: "Crit if capacity is above this threshold",
21
+ description: "Crit if capacity in percent is above this threshold",
22
22
  default: 90
23
23
 
24
+ option :scrubbing_interval,
25
+ short: "-s DAYS",
26
+ long: "--scrubbing-interval DAYS",
27
+ description: "Warn it is more than this number of days since last scrub",
28
+ default: 7
29
+
24
30
  def run
25
31
  zpools = []
26
32
  if config[:zpool]
@@ -32,6 +38,7 @@ class CheckZPool < Sensu::Plugin::Check::CLI
32
38
  check_state zp
33
39
  check_vdevs zp
34
40
  check_capacity zp
41
+ check_recently_scrubbed zp
35
42
  end
36
43
  if config[:zpool]
37
44
  ok "zpool #{config[:zpool]} is ok"
@@ -62,4 +69,11 @@ class CheckZPool < Sensu::Plugin::Check::CLI
62
69
  warning "capacity for zpool #{zp.name} is above #{config[:cap_warn]}% (currently #{zp.capacity}%)"
63
70
  end
64
71
  end
72
+
73
+ def check_recently_scrubbed(zp)
74
+ last_scrub = zp.scrubbed_at
75
+ if last_scrub > Time.now - 60 * 60 * 24 * config[:scrubbing_interval]
76
+ warning "It is more than #{config[:scrubbing_interval]} days since zpool #{zp.name} was scrubbed. Last scrubbed #{last_scrub.to_s}"
77
+ end
78
+ end
65
79
  end
@@ -1,3 +1,3 @@
1
1
  module SensuPluginsZFS
2
- VERSION = "1.1.2"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -1,3 +1,5 @@
1
+ require "time"
2
+
1
3
  module SensuPluginsZFS
2
4
  class ZFS
3
5
  def self.zpools
@@ -13,12 +15,21 @@ module SensuPluginsZFS
13
15
  def initialize(name)
14
16
  @name = name
15
17
  @state = %x[sudo zpool status #{name} | grep '^ state: ' | cut -d ' ' -f 3].strip
16
- @capacity = %x[zpool get -H capacity #{@name} | awk '{print $3}' | cut -d '%' -f1].strip.to_i
18
+ @capacity = %x[sudo zpool get -H capacity #{@name} | awk '{print $3}' | cut -d '%' -f1].strip.to_i
17
19
  @vdevs = create_vdevs name
18
20
  end
19
21
 
20
22
  def ok?
21
- return @state == "ONLINE"
23
+ @state == "ONLINE"
24
+ end
25
+
26
+ def scrubbed_at
27
+ if never_scrubbed?
28
+ return Time.at(0)
29
+ elsif scrub_in_progress?
30
+ return Time.now
31
+ end
32
+ Time.parse %[zpool status tank | grep '^ scan: scrub' | awk '{print $11" "$12" "$13" "$14" "$15}'].strip
22
33
  end
23
34
 
24
35
  private
@@ -30,6 +41,14 @@ module SensuPluginsZFS
30
41
  VDev.new(self, arr[0], arr[1], arr[2].to_i, arr[3].to_i, arr[4].to_i)
31
42
  end
32
43
  end
44
+
45
+ def never_scrubbed?
46
+ %x[sudo zpool status #{@name} | egrep -c "none requested"].strip.to_i == 1
47
+ end
48
+
49
+ def scrub_in_progress?
50
+ %x[sudo zpool status #{@name} | egrep -c "scrub in progress|resilver"].strip.to_i == 1
51
+ end
33
52
  end
34
53
 
35
54
  class VDev
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-zfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Nørgaard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-21 00:00:00.000000000 Z
11
+ date: 2017-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin