sensu-plugins-zfs 1.0.6 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b341e26b5d3f60dbc4642b1a8ced419af25ec84a
4
- data.tar.gz: 99654f826a95b1540402594b0e4f390ee43a8ffb
3
+ metadata.gz: 7c3a3744fcbbe19ac49cf6e968082a6b6f1aa392
4
+ data.tar.gz: 11e6ac61a97cd02a890c980d4fb52fdf8ad2223e
5
5
  SHA512:
6
- metadata.gz: 3d72b51b7b093db3956e8d37b541d7e871859267702090bac82b0c4a58ad99be373ae9cb6e21b3e248e6b743536fe5905ddefc6415252daac17233e6aae2fd63
7
- data.tar.gz: 88497e12945e9818f1c43f56a63668eed32fa2a06d20a2819b9f89f146ed44efc9b11dc56bc4a1563037057dbfce2e9f2db4f3edaba7fb740858914c84c68b83
6
+ metadata.gz: ba3d899bfe554cdf8c1e0633b85618b98d7b18a21352f2d8f149e5a8d300450c4429769d0b278f1bc7862bdb2170231beb1aa175b53b9a3fb9b3a61e1fce830c
7
+ data.tar.gz: c8552e5482f078fd8071237bc953c640714edf9d0da8c481d7fb114f635454fc5c90362d9af38870c867819923367dac0fbde48fb1fc25479d5be6f75398e2b5
data/README.md CHANGED
@@ -1,21 +1,27 @@
1
1
  # SensuPluginsZFS
2
2
 
3
- Sensu plugin for zfs checks.
4
-
5
- So far we just got a simple plugin that checks if the zpool is online.
3
+ Sensu plugin for zfs health checks.
6
4
 
7
5
  ## Checks
8
6
 
9
7
  ### check-zpool.rb
10
8
 
11
- Checks if the zpool state is ONLINE
9
+ Checks if the zpool state is ONLINE and wether there has been any errors on
10
+ vdevs.
11
+
12
+ - `-z, --zpool` What zpool to check. If omitted, we check all zpools.
12
13
 
13
14
  ## Installation
14
15
  [Installation and setup](http://sensu-plugins.io/docs/installation_instructions.html)
15
16
 
16
17
  ## Contributing
17
18
 
18
- That this time ideas for additional checks/metrics would be very much appreciated.
19
+ At this time ideas for additional checks/metrics would be very much appreciated.
20
+
21
+ I have a few ideas that would be nice:
22
+
23
+ - [ ] Check that disks have been scrubbed recently
24
+ - [ ] Check/metric for pool capacity
19
25
 
20
26
  Bug reports and pull requests are welcome on GitHub at https://github.com/blacksails/sensu-plugins-zfs.
21
27
 
data/bin/check-zpool.rb CHANGED
@@ -9,6 +9,18 @@ class CheckZPool < Sensu::Plugin::Check::CLI
9
9
  long: "--zpool ZPOOL",
10
10
  description: "Name of zpool to check. If omitted, we check all zpools"
11
11
 
12
+ option :cap_warn,
13
+ short: "-c PERCENTAGE",
14
+ long: "--capacity-warn PERCENTAGE",
15
+ description: "Warn if capacity is above this threshold",
16
+ default: 80
17
+
18
+ option :cap_crit,
19
+ short: "-C PERCENTAGE",
20
+ long: "--capacity-crit PERCENTAGE",
21
+ description: "Crit if capacity is above this threshold",
22
+ default: 90
23
+
12
24
  def run
13
25
  zpools = []
14
26
  if config[:zpool]
@@ -19,6 +31,7 @@ class CheckZPool < Sensu::Plugin::Check::CLI
19
31
  zpools.each do |zp|
20
32
  check_state zp
21
33
  check_vdevs zp
34
+ check_capacity zp
22
35
  end
23
36
  if config[:zpool]
24
37
  ok "zpool #{config[:zpool]} is ok"
@@ -41,4 +54,12 @@ class CheckZPool < Sensu::Plugin::Check::CLI
41
54
  end
42
55
  end
43
56
  end
57
+
58
+ def check_capacity(zp)
59
+ if zp.capacity > config[:cap_crit]
60
+ critical "capacity for zpool #{zp.name} is above #{config[:cap_crit}% (currently #{zp.capacity}%)"
61
+ elsif zp.capacity > config[:warn_crit]
62
+ warning "capacity for zpool #{zp.name} is above #{config[:cap_warn}% (currently #{zp.capacity}%)"
63
+ end
64
+ end
44
65
  end
@@ -1,3 +1,3 @@
1
1
  module SensuPluginsZFS
2
- VERSION = "1.0.6"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -8,11 +8,12 @@ module SensuPluginsZFS
8
8
  end
9
9
 
10
10
  class ZPool
11
- attr_reader :state, :name, :vdevs
11
+ attr_reader :name, :state, :capacity, :vdevs
12
12
 
13
13
  def initialize(name)
14
14
  @name = name
15
15
  @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
16
17
  @vdevs = create_vdevs name
17
18
  end
18
19
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-zfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Nørgaard