check_zfs 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -0
- data/bin/check_zfs +10 -24
- data/check_zfs.gemspec +3 -2
- data/features/check_zfs.feature +6 -6
- metadata +77 -101
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.2@check_zfs --create
|
data/bin/check_zfs
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby -w
|
2
|
-
require '
|
2
|
+
require 'nagiosplugin'
|
3
3
|
|
4
|
-
class
|
4
|
+
class ZFS < NagiosPlugin::Plugin
|
5
5
|
def zpools
|
6
|
-
|
7
|
-
raise
|
8
|
-
|
6
|
+
out = `zpool list -H -o name,health 2>&1`
|
7
|
+
raise out unless $?.success?
|
8
|
+
out.split("\n")
|
9
9
|
end
|
10
10
|
|
11
11
|
def health_by_pool
|
@@ -20,39 +20,25 @@ class CheckZFS < Nagios::Probe
|
|
20
20
|
(health && health_by_pool.select { |p,h| h == health.to_s.upcase } ) || health_by_pool
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
23
|
+
def critical?
|
24
24
|
!pools(:faulted).empty?
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def warning?
|
28
28
|
!pools(:degraded).empty?
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def ok?
|
32
32
|
pools(:online).count == pools.count
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
35
|
+
def output
|
36
36
|
s = []
|
37
37
|
[:faulted, :degraded, :online].each do |health|
|
38
38
|
s << "#{pools(health).count} #{health.to_s.upcase}" unless pools(health).empty?
|
39
39
|
end
|
40
40
|
s.join(", ")
|
41
41
|
end
|
42
|
-
|
43
|
-
alias :crit_message :info
|
44
|
-
alias :warn_message :info
|
45
|
-
alias :ok_message :info
|
46
|
-
end
|
47
|
-
|
48
|
-
begin
|
49
|
-
options = {} # Nagios::Probe constructor accepts a single optional param that is assigned to @opts
|
50
|
-
probe = CheckZFS.new(options)
|
51
|
-
probe.run
|
52
|
-
rescue Exception => e
|
53
|
-
puts "Unknown: " + e
|
54
|
-
exit Nagios::UNKNOWN
|
55
42
|
end
|
56
43
|
|
57
|
-
|
58
|
-
exit probe.retval
|
44
|
+
ZFS.check!
|
data/check_zfs.gemspec
CHANGED
@@ -2,15 +2,16 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'check_zfs'
|
5
|
-
s.version = '0.0
|
5
|
+
s.version = '0.1.0'
|
6
6
|
s.authors = ["Björn Albers"]
|
7
7
|
s.email = ["bjoernalbers@googlemail.com"]
|
8
8
|
s.description = 'Monitor the health of your ZFS pools with Nagios'
|
9
9
|
s.summary = "#{s.name}-#{s.version}"
|
10
10
|
s.homepage = 'https://github.com/bjoernalbers/check_zfs'
|
11
11
|
|
12
|
-
s.add_dependency '
|
12
|
+
s.add_dependency 'nagiosplugin', '~> 0.0.3'
|
13
13
|
|
14
|
+
s.add_development_dependency 'rake'
|
14
15
|
s.add_development_dependency 'cucumber', '>= 1.0.2'
|
15
16
|
s.add_development_dependency 'aruba', '>= 0.4.6'
|
16
17
|
s.add_development_dependency 'aruba-doubles', '>= 0.2.0'
|
data/features/check_zfs.feature
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Feature: Check ZFS
|
2
2
|
|
3
|
-
In order to notified before it's to late
|
3
|
+
In order to be notified before it's to late
|
4
4
|
As an agile System-Administrator
|
5
5
|
I want the health of my ZFS pools monitored with Nagios by check_zfs
|
6
6
|
|
@@ -15,15 +15,15 @@ Feature: Check ZFS
|
|
15
15
|
Then the exit status should be <exit>
|
16
16
|
And the stdout should contain exactly:
|
17
17
|
"""
|
18
|
-
<
|
18
|
+
ZFS <output>
|
19
19
|
|
20
20
|
"""
|
21
21
|
|
22
22
|
Examples:
|
23
|
-
| rpool | tank | tank2 | exit |
|
23
|
+
| rpool | tank | tank2 | exit | output |
|
24
24
|
| ONLINE | ONLINE | ONLINE | 0 | OK: 3 ONLINE |
|
25
|
-
| ONLINE | DEGRADED | ONLINE | 1 |
|
26
|
-
| ONLINE | DEGRADED | FAULTED | 2 |
|
25
|
+
| ONLINE | DEGRADED | ONLINE | 1 | WARNING: 1 DEGRADED, 2 ONLINE |
|
26
|
+
| ONLINE | DEGRADED | FAULTED | 2 | CRITICAL: 1 FAULTED, 1 DEGRADED, 1 ONLINE |
|
27
27
|
|
28
28
|
Scenario: Missing zpool command
|
29
29
|
Given I could run `zpool list -H -o name,health` with exit status 127 and stderr:
|
@@ -32,4 +32,4 @@ Feature: Check ZFS
|
|
32
32
|
"""
|
33
33
|
When I run `check_zfs`
|
34
34
|
Then the exit status should be 3
|
35
|
-
And the stdout should contain "
|
35
|
+
And the stdout should contain "ZFS UNKNOWN: command not found: zpool"
|
metadata
CHANGED
@@ -1,113 +1,92 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: check_zfs
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 3
|
10
|
-
version: 0.0.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
7
|
+
authors:
|
8
|
+
- Björn Albers
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2011-12-31 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nagiosplugin
|
16
|
+
requirement: &70360989688380 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
- 1
|
32
|
-
- 2
|
33
|
-
version: 0.1.2
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.0.3
|
34
22
|
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: cucumber
|
38
23
|
prerelease: false
|
39
|
-
|
24
|
+
version_requirements: *70360989688380
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &70360989687540 !ruby/object:Gem::Requirement
|
40
28
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70360989687540
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: cucumber
|
38
|
+
requirement: &70360989685880 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
49
43
|
version: 1.0.2
|
50
44
|
type: :development
|
51
|
-
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: aruba
|
54
45
|
prerelease: false
|
55
|
-
|
46
|
+
version_requirements: *70360989685880
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: aruba
|
49
|
+
requirement: &70360989684200 !ruby/object:Gem::Requirement
|
56
50
|
none: false
|
57
|
-
requirements:
|
58
|
-
- -
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
hash: 3
|
61
|
-
segments:
|
62
|
-
- 0
|
63
|
-
- 4
|
64
|
-
- 6
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
65
54
|
version: 0.4.6
|
66
55
|
type: :development
|
67
|
-
version_requirements: *id003
|
68
|
-
- !ruby/object:Gem::Dependency
|
69
|
-
name: aruba-doubles
|
70
56
|
prerelease: false
|
71
|
-
|
57
|
+
version_requirements: *70360989684200
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: aruba-doubles
|
60
|
+
requirement: &70360989683080 !ruby/object:Gem::Requirement
|
72
61
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
hash: 23
|
77
|
-
segments:
|
78
|
-
- 0
|
79
|
-
- 2
|
80
|
-
- 0
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
81
65
|
version: 0.2.0
|
82
66
|
type: :development
|
83
|
-
version_requirements: *id004
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: guard-cucumber
|
86
67
|
prerelease: false
|
87
|
-
|
68
|
+
version_requirements: *70360989683080
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-cucumber
|
71
|
+
requirement: &70360989682240 !ruby/object:Gem::Requirement
|
88
72
|
none: false
|
89
|
-
requirements:
|
90
|
-
- -
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
hash: 5
|
93
|
-
segments:
|
94
|
-
- 0
|
95
|
-
- 7
|
96
|
-
- 3
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
97
76
|
version: 0.7.3
|
98
77
|
type: :development
|
99
|
-
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70360989682240
|
100
80
|
description: Monitor the health of your ZFS pools with Nagios
|
101
|
-
email:
|
81
|
+
email:
|
102
82
|
- bjoernalbers@googlemail.com
|
103
|
-
executables:
|
83
|
+
executables:
|
104
84
|
- check_zfs
|
105
85
|
extensions: []
|
106
|
-
|
107
86
|
extra_rdoc_files: []
|
108
|
-
|
109
|
-
files:
|
87
|
+
files:
|
110
88
|
- .gitignore
|
89
|
+
- .rvmrc
|
111
90
|
- Gemfile
|
112
91
|
- Guardfile
|
113
92
|
- LICENSE
|
@@ -120,37 +99,34 @@ files:
|
|
120
99
|
- lib/check_zfs.rb
|
121
100
|
homepage: https://github.com/bjoernalbers/check_zfs
|
122
101
|
licenses: []
|
123
|
-
|
124
102
|
post_install_message:
|
125
103
|
rdoc_options: []
|
126
|
-
|
127
|
-
require_paths:
|
104
|
+
require_paths:
|
128
105
|
- lib
|
129
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
107
|
none: false
|
131
|
-
requirements:
|
132
|
-
- -
|
133
|
-
- !ruby/object:Gem::Version
|
134
|
-
|
135
|
-
segments:
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
segments:
|
136
113
|
- 0
|
137
|
-
|
138
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
hash: 672083281411555788
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
116
|
none: false
|
140
|
-
requirements:
|
141
|
-
- -
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
|
144
|
-
segments:
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
segments:
|
145
122
|
- 0
|
146
|
-
|
123
|
+
hash: 672083281411555788
|
147
124
|
requirements: []
|
148
|
-
|
149
125
|
rubyforge_project:
|
150
|
-
rubygems_version: 1.8.
|
126
|
+
rubygems_version: 1.8.10
|
151
127
|
signing_key:
|
152
128
|
specification_version: 3
|
153
|
-
summary: check_zfs-0.0
|
154
|
-
test_files:
|
129
|
+
summary: check_zfs-0.1.0
|
130
|
+
test_files:
|
155
131
|
- features/check_zfs.feature
|
156
132
|
- features/support/env.rb
|