steto 0.0.1 → 0.0.2
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.
- data/lib/steto/cocaine_ext.rb +1 -1
- data/lib/steto/engine.rb +6 -1
- data/lib/steto/nagios_check.rb +11 -5
- data/lib/steto/proc_check.rb +17 -1
- data/lib/steto/version.rb +1 -1
- data/spec/steto/engine_spec.rb +9 -0
- data/spec/steto/nagios_check_spec.rb +9 -0
- data/spec/steto/proc_check_spec.rb +30 -0
- metadata +6 -4
data/lib/steto/cocaine_ext.rb
CHANGED
data/lib/steto/engine.rb
CHANGED
data/lib/steto/nagios_check.rb
CHANGED
@@ -6,6 +6,7 @@ module Steto
|
|
6
6
|
attr_accessor :command, :options
|
7
7
|
|
8
8
|
def initialize(attributes = {})
|
9
|
+
self.command = ""
|
9
10
|
self.options = {}
|
10
11
|
self.attributes = attributes
|
11
12
|
end
|
@@ -29,11 +30,16 @@ module Steto
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def status_from_command_line
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
case command_line.exit_status
|
34
|
+
when 0
|
35
|
+
:ok
|
36
|
+
when 1
|
37
|
+
:warning
|
38
|
+
when 2
|
39
|
+
:critical
|
40
|
+
else
|
41
|
+
:unknown
|
42
|
+
end
|
37
43
|
end
|
38
44
|
|
39
45
|
end
|
data/lib/steto/proc_check.rb
CHANGED
@@ -7,7 +7,23 @@ module Steto
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def check
|
10
|
-
self.status = @block.call
|
10
|
+
self.status = status_from_response(@block.call)
|
11
11
|
end
|
12
|
+
|
13
|
+
def status_from_response(response)
|
14
|
+
case response
|
15
|
+
when Steto::Status
|
16
|
+
response
|
17
|
+
when Symbol
|
18
|
+
Status.new(response)
|
19
|
+
when true
|
20
|
+
Status.new(:ok)
|
21
|
+
when false
|
22
|
+
Status.new(:critical)
|
23
|
+
when nil
|
24
|
+
Status.new(:unknown)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
12
28
|
end
|
13
29
|
end
|
data/lib/steto/version.rb
CHANGED
data/spec/steto/engine_spec.rb
CHANGED
@@ -12,6 +12,15 @@ describe Steto::Engine do
|
|
12
12
|
subject.check
|
13
13
|
end
|
14
14
|
|
15
|
+
it "should set as unknown a failing check" do
|
16
|
+
failing_check = Steto::ProcCheck.new(:name => :fail) do
|
17
|
+
raise "fail"
|
18
|
+
end
|
19
|
+
subject.checks << failing_check
|
20
|
+
subject.check
|
21
|
+
failing_check.status.should be_unknown
|
22
|
+
end
|
23
|
+
|
15
24
|
end
|
16
25
|
|
17
26
|
describe "#config" do
|
@@ -45,4 +45,13 @@ describe Steto::NagiosCheck do
|
|
45
45
|
|
46
46
|
end
|
47
47
|
|
48
|
+
describe "#status_from_command_line" do
|
49
|
+
|
50
|
+
it "should return unknown when exitstatus is not defined" do
|
51
|
+
subject.command_line.stub :exit_status => nil
|
52
|
+
subject.status_from_command_line.should == :unknown
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
48
57
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Steto::ProcCheck do
|
4
|
+
|
5
|
+
describe "#status_from_response" do
|
6
|
+
|
7
|
+
it "should return ok when response is true" do
|
8
|
+
subject.status_from_response(true).should be_ok
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return critical when response is false" do
|
12
|
+
subject.status_from_response(false).should be_critical
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return unknown when response is nil" do
|
16
|
+
subject.status_from_response(nil).should be_unknown
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return a Status when response is Symbol" do
|
20
|
+
subject.status_from_response(:ok).should be_ok
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return the response when it is a Status" do
|
24
|
+
subject.status_from_response(Steto::Status.new(:ok)).should be_ok
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: steto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alban Peignier
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-05-
|
19
|
+
date: 2012-05-30 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
prerelease: false
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- spec/steto/engine_spec.rb
|
139
139
|
- spec/steto/logger_reporter_spec.rb
|
140
140
|
- spec/steto/nagios_check_spec.rb
|
141
|
+
- spec/steto/proc_check_spec.rb
|
141
142
|
- steto.gemspec
|
142
143
|
homepage: https://github.com/tryphon/steto
|
143
144
|
licenses: []
|
@@ -179,3 +180,4 @@ test_files:
|
|
179
180
|
- spec/steto/engine_spec.rb
|
180
181
|
- spec/steto/logger_reporter_spec.rb
|
181
182
|
- spec/steto/nagios_check_spec.rb
|
183
|
+
- spec/steto/proc_check_spec.rb
|