sensu-extensions 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -4
- data/lib/sensu/extensions.rb +7 -0
- data/lib/sensu/extensions/constants.rb +8 -0
- data/lib/sensu/extensions/loader.rb +43 -4
- data/sensu-extensions.gemspec +7 -2
- data/spec/extensions_spec.rb +13 -0
- data/spec/helpers.rb +0 -5
- data/spec/loader_spec.rb +13 -0
- metadata +79 -20
- data/lib/sensu/extensions/handlers/debug.rb +0 -19
- data/lib/sensu/extensions/mutators/json.rb +0 -20
- data/lib/sensu/extensions/mutators/only_check_output.rb +0 -19
- data/lib/sensu/extensions/mutators/ruby_hash.rb +0 -19
- data/spec/handlers/debug_spec.rb +0 -24
- data/spec/mutators/json_spec.rb +0 -24
- data/spec/mutators/only_check_output_spec.rb +0 -24
- data/spec/mutators/ruby_hash_spec.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b32c7fca1bc576173c52ae95e807c0ac956b80e4
|
4
|
+
data.tar.gz: a48a681d4c47335c25ed8e1fc48e77fc89f05b2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1df857fbe88e71076e8afe89a3cc82a863c44cc968352d55d0241435fc9bb231c1a293b51f611245ad541ce71d78cad81ee85e8927697dedf37ffe876396144d
|
7
|
+
data.tar.gz: b851603af885525417fb1dec2558aa9cf451fbd926a80f26d1e4d5e20b61e80cb181aa01b5fbb7f97a960a1da4b222e5e137d6af497d46d5db149dd2fd2ff94c
|
data/.travis.yml
CHANGED
@@ -6,10 +6,11 @@ rvm:
|
|
6
6
|
- 2.2.0
|
7
7
|
- 2.2.3
|
8
8
|
- 2.3.0
|
9
|
-
- jruby-
|
9
|
+
- jruby-9.0.5.0
|
10
|
+
before_install:
|
11
|
+
- gem update --system
|
12
|
+
- gem --version
|
13
|
+
- gem install bundler --version 1.11.2
|
10
14
|
notifications:
|
11
15
|
irc:
|
12
16
|
- "irc.freenode.net#sensu"
|
13
|
-
addons:
|
14
|
-
code_climate:
|
15
|
-
repo_token: e2001d0db82d5835d76a70d025388fee457bd4243fda3e046097e9d6db28fe5d
|
data/lib/sensu/extensions.rb
CHANGED
@@ -9,6 +9,7 @@ module Sensu
|
|
9
9
|
# @option options [String] :extension_file to load.
|
10
10
|
# @option options [String] :extension_dir to load.
|
11
11
|
# @option options [Array] :extension_dirs to load.
|
12
|
+
# @option options [Hash] :extensions to load (gems).
|
12
13
|
# @return [Loader] a loaded instance of Loader.
|
13
14
|
def load(options={})
|
14
15
|
@loader = Loader.new
|
@@ -23,6 +24,12 @@ module Sensu
|
|
23
24
|
@loader.load_directory(directory)
|
24
25
|
end
|
25
26
|
end
|
27
|
+
if options[:extensions]
|
28
|
+
options[:extensions].each do |name, details|
|
29
|
+
gem_name = details[:gem] || "#{GEM_PREFIX}#{name}"
|
30
|
+
@loader.load_gem(gem_name, details[:version])
|
31
|
+
end
|
32
|
+
end
|
26
33
|
@loader.load_instances
|
27
34
|
@loader
|
28
35
|
end
|
@@ -1,8 +1,16 @@
|
|
1
|
+
gem "sensu-extensions-occurrences", "1.0.0"
|
2
|
+
gem "sensu-extensions-json", "1.0.0"
|
3
|
+
gem "sensu-extensions-ruby-hash", "1.0.0"
|
4
|
+
gem "sensu-extensions-only-check-output", "1.0.0"
|
5
|
+
gem "sensu-extensions-debug", "1.0.0"
|
6
|
+
|
1
7
|
require "sensu/extension"
|
2
|
-
require "sensu/extensions/
|
3
|
-
require "sensu/extensions/
|
4
|
-
require "sensu/extensions/
|
5
|
-
require "sensu/extensions/
|
8
|
+
require "sensu/extensions/constants"
|
9
|
+
require "sensu/extensions/occurrences"
|
10
|
+
require "sensu/extensions/json"
|
11
|
+
require "sensu/extensions/ruby-hash"
|
12
|
+
require "sensu/extensions/only-check-output"
|
13
|
+
require "sensu/extensions/debug"
|
6
14
|
|
7
15
|
module Sensu
|
8
16
|
module Extensions
|
@@ -15,9 +23,14 @@ module Sensu
|
|
15
23
|
# @return [Array] loaded extension files.
|
16
24
|
attr_reader :loaded_files
|
17
25
|
|
26
|
+
# @!attribute [r] loaded_gems
|
27
|
+
# @return [Array] loaded extension gems.
|
28
|
+
attr_reader :loaded_gems
|
29
|
+
|
18
30
|
def initialize
|
19
31
|
@warnings = []
|
20
32
|
@loaded_files = []
|
33
|
+
@loaded_gems = []
|
21
34
|
@extensions = {}
|
22
35
|
Extension::CATEGORIES.each do |category|
|
23
36
|
@extensions[category] = {}
|
@@ -85,6 +98,32 @@ module Sensu
|
|
85
98
|
end
|
86
99
|
end
|
87
100
|
|
101
|
+
# Load an extension from a Rubygem.
|
102
|
+
#
|
103
|
+
# @param [String] gem name.
|
104
|
+
def load_gem(raw_gem, version=nil)
|
105
|
+
warning("loading extension gem", :gem => raw_gem, :version => version)
|
106
|
+
begin
|
107
|
+
gem(raw_gem, version) if version
|
108
|
+
if raw_gem.start_with?(GEM_PREFIX)
|
109
|
+
lib = raw_gem.sub(/^#{GEM_PREFIX}/, "")
|
110
|
+
require_path = "sensu/extensions/#{lib}"
|
111
|
+
else
|
112
|
+
require_path = raw_gem
|
113
|
+
end
|
114
|
+
warning("requiring extension gem", :require => require_path)
|
115
|
+
require require_path
|
116
|
+
@loaded_gems << raw_gem
|
117
|
+
rescue ScriptError, StandardError => error
|
118
|
+
warning("failed to require extension", {
|
119
|
+
:gem => raw_gem,
|
120
|
+
:version => version,
|
121
|
+
:error => error
|
122
|
+
})
|
123
|
+
warning("ignoring extension", :gem => raw_gem)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
88
127
|
# Load instances of the loaded extensions.
|
89
128
|
#
|
90
129
|
# @param [String] sensu service to load extensions for.
|
data/sensu-extensions.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "sensu-extensions"
|
5
|
-
spec.version = "1.
|
5
|
+
spec.version = "1.6.0"
|
6
6
|
spec.authors = ["Sean Porter"]
|
7
7
|
spec.email = ["portertech@gmail.com"]
|
8
8
|
spec.summary = "The Sensu extension loader library"
|
@@ -19,10 +19,15 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.add_dependency "sensu-logger"
|
20
20
|
spec.add_dependency "sensu-settings"
|
21
21
|
spec.add_dependency "sensu-extension"
|
22
|
+
spec.add_dependency "sensu-extensions-occurrences", "1.0.0"
|
23
|
+
spec.add_dependency "sensu-extensions-json", "1.0.0"
|
24
|
+
spec.add_dependency "sensu-extensions-ruby-hash", "1.0.0"
|
25
|
+
spec.add_dependency "sensu-extensions-only-check-output", "1.0.0"
|
26
|
+
spec.add_dependency "sensu-extensions-debug", "1.0.0"
|
22
27
|
|
23
28
|
spec.add_development_dependency "bundler", "~> 1.6"
|
24
29
|
spec.add_development_dependency "rake"
|
25
30
|
spec.add_development_dependency "rspec"
|
31
|
+
spec.add_development_dependency "sensu-extensions-system-profile", "1.0.0"
|
26
32
|
spec.add_development_dependency "bouncy-castle-java" if RUBY_PLATFORM =~ /java/
|
27
|
-
spec.add_development_dependency "codeclimate-test-reporter"
|
28
33
|
end
|
data/spec/extensions_spec.rb
CHANGED
@@ -54,9 +54,22 @@ describe "Sensu::Extensions" do
|
|
54
54
|
|
55
55
|
it "can load the built-in extensions" do
|
56
56
|
extensions = Sensu::Extensions.load
|
57
|
+
expect(extensions.filter_exists?("occurrences")).to be(true)
|
57
58
|
expect(extensions.mutator_exists?("json")).to be(true)
|
58
59
|
expect(extensions.mutator_exists?("ruby_hash")).to be(true)
|
59
60
|
expect(extensions.mutator_exists?("only_check_output")).to be(true)
|
60
61
|
expect(extensions.handler_exists?("debug")).to be(true)
|
61
62
|
end
|
63
|
+
|
64
|
+
it "can load extensions from gems" do
|
65
|
+
options = {
|
66
|
+
:extensions => {
|
67
|
+
"system-profile" => {
|
68
|
+
:version => "1.0.0"
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
extensions = Sensu::Extensions.load(options)
|
73
|
+
expect(extensions.check_exists?("system_profile")).to be(true)
|
74
|
+
end
|
62
75
|
end
|
data/spec/helpers.rb
CHANGED
@@ -4,11 +4,6 @@ require "sensu/logger"
|
|
4
4
|
require "sensu/settings"
|
5
5
|
require "securerandom"
|
6
6
|
|
7
|
-
unless RUBY_VERSION < "1.9" || RUBY_PLATFORM =~ /java/
|
8
|
-
require "codeclimate-test-reporter"
|
9
|
-
CodeClimate::TestReporter.start
|
10
|
-
end
|
11
|
-
|
12
7
|
module Helpers
|
13
8
|
def timer(delay, &callback)
|
14
9
|
periodic_timer = EM::PeriodicTimer.new(delay) do
|
data/spec/loader_spec.rb
CHANGED
@@ -63,6 +63,7 @@ describe "Sensu::Extensions::Loader" do
|
|
63
63
|
expect(extension).to respond_to(:name, :name_alias, :description, :definition, :safe_run, :stop, :has_key?, :[])
|
64
64
|
expect(@loader.handlers).to include(extension.definition)
|
65
65
|
expect(@loader.all).to include(extension)
|
66
|
+
expect(@loader.filter_exists?("occurrences")).to be(true)
|
66
67
|
expect(@loader.mutator_exists?("json")).to be(true)
|
67
68
|
expect(@loader.mutator_exists?("ruby_hash")).to be(true)
|
68
69
|
expect(@loader.mutator_exists?("only_check_output")).to be(true)
|
@@ -99,4 +100,16 @@ describe "Sensu::Extensions::Loader" do
|
|
99
100
|
expect(@loader.mutator_exists?("only_check_output")).to be(true)
|
100
101
|
expect(@loader.check_exists?("mock_check")).to be(false)
|
101
102
|
end
|
103
|
+
|
104
|
+
it "can load a specific extension from a gem" do
|
105
|
+
@loader.load_gem("sensu-extensions-system-profile", "1.0.0")
|
106
|
+
@loader.load_instances
|
107
|
+
expect(@loader.loaded_gems).to include("sensu-extensions-system-profile")
|
108
|
+
expect(@loader.check_exists?("system_profile")).to be(true)
|
109
|
+
extension = @loader[:checks]["system_profile"]
|
110
|
+
expect(extension).to be_instance_of(Sensu::Extension::SystemProfile)
|
111
|
+
expect(extension).to respond_to(:name, :name_alias, :description, :definition, :safe_run, :stop, :has_key?, :[])
|
112
|
+
expect(@loader.checks).to include(extension.definition)
|
113
|
+
expect(@loader.all).to include(extension)
|
114
|
+
end
|
102
115
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Porter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-json
|
@@ -66,6 +66,76 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sensu-extensions-occurrences
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.0.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.0.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sensu-extensions-json
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.0.0
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.0.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sensu-extensions-ruby-hash
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.0.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.0.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sensu-extensions-only-check-output
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.0.0
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.0.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: sensu-extensions-debug
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.0.0
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.0.0
|
69
139
|
- !ruby/object:Gem::Dependency
|
70
140
|
name: bundler
|
71
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,19 +179,19 @@ dependencies:
|
|
109
179
|
- !ruby/object:Gem::Version
|
110
180
|
version: '0'
|
111
181
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
182
|
+
name: sensu-extensions-system-profile
|
113
183
|
requirement: !ruby/object:Gem::Requirement
|
114
184
|
requirements:
|
115
|
-
- -
|
185
|
+
- - '='
|
116
186
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
187
|
+
version: 1.0.0
|
118
188
|
type: :development
|
119
189
|
prerelease: false
|
120
190
|
version_requirements: !ruby/object:Gem::Requirement
|
121
191
|
requirements:
|
122
|
-
- -
|
192
|
+
- - '='
|
123
193
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
194
|
+
version: 1.0.0
|
125
195
|
description: The Sensu extension loader library
|
126
196
|
email:
|
127
197
|
- portertech@gmail.com
|
@@ -136,11 +206,8 @@ files:
|
|
136
206
|
- README.md
|
137
207
|
- Rakefile
|
138
208
|
- lib/sensu/extensions.rb
|
139
|
-
- lib/sensu/extensions/
|
209
|
+
- lib/sensu/extensions/constants.rb
|
140
210
|
- lib/sensu/extensions/loader.rb
|
141
|
-
- lib/sensu/extensions/mutators/json.rb
|
142
|
-
- lib/sensu/extensions/mutators/only_check_output.rb
|
143
|
-
- lib/sensu/extensions/mutators/ruby_hash.rb
|
144
211
|
- sensu-extensions.gemspec
|
145
212
|
- spec/assets/config.json
|
146
213
|
- spec/assets/extensions/error.rb
|
@@ -149,12 +216,8 @@ files:
|
|
149
216
|
- spec/assets/extensions/test.rb
|
150
217
|
- spec/assets/extensions_symlinked/symlinked_check.rb
|
151
218
|
- spec/extensions_spec.rb
|
152
|
-
- spec/handlers/debug_spec.rb
|
153
219
|
- spec/helpers.rb
|
154
220
|
- spec/loader_spec.rb
|
155
|
-
- spec/mutators/json_spec.rb
|
156
|
-
- spec/mutators/only_check_output_spec.rb
|
157
|
-
- spec/mutators/ruby_hash_spec.rb
|
158
221
|
homepage: https://github.com/sensu/sensu-extensions
|
159
222
|
licenses:
|
160
223
|
- MIT
|
@@ -175,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
238
|
version: '0'
|
176
239
|
requirements: []
|
177
240
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.
|
241
|
+
rubygems_version: 2.6.3
|
179
242
|
signing_key:
|
180
243
|
specification_version: 4
|
181
244
|
summary: The Sensu extension loader library
|
@@ -187,9 +250,5 @@ test_files:
|
|
187
250
|
- spec/assets/extensions/test.rb
|
188
251
|
- spec/assets/extensions_symlinked/symlinked_check.rb
|
189
252
|
- spec/extensions_spec.rb
|
190
|
-
- spec/handlers/debug_spec.rb
|
191
253
|
- spec/helpers.rb
|
192
254
|
- spec/loader_spec.rb
|
193
|
-
- spec/mutators/json_spec.rb
|
194
|
-
- spec/mutators/only_check_output_spec.rb
|
195
|
-
- spec/mutators/ruby_hash_spec.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require "sensu/extension"
|
2
|
-
require "sensu/json"
|
3
|
-
|
4
|
-
module Sensu
|
5
|
-
module Extension
|
6
|
-
class Json < Mutator
|
7
|
-
def name
|
8
|
-
"json"
|
9
|
-
end
|
10
|
-
|
11
|
-
def description
|
12
|
-
"returns JSON formatted event data"
|
13
|
-
end
|
14
|
-
|
15
|
-
def run(event)
|
16
|
-
yield Sensu::JSON.dump(event), 0
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require "sensu/extension"
|
2
|
-
|
3
|
-
module Sensu
|
4
|
-
module Extension
|
5
|
-
class OnlyCheckOutput < Mutator
|
6
|
-
def name
|
7
|
-
"only_check_output"
|
8
|
-
end
|
9
|
-
|
10
|
-
def description
|
11
|
-
"returns check output"
|
12
|
-
end
|
13
|
-
|
14
|
-
def run(event)
|
15
|
-
yield event[:check][:output], 0
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require "sensu/extension"
|
2
|
-
|
3
|
-
module Sensu
|
4
|
-
module Extension
|
5
|
-
class RubyHash < Mutator
|
6
|
-
def name
|
7
|
-
"ruby_hash"
|
8
|
-
end
|
9
|
-
|
10
|
-
def description
|
11
|
-
"returns ruby hash event data"
|
12
|
-
end
|
13
|
-
|
14
|
-
def run(event)
|
15
|
-
yield event, 0
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/spec/handlers/debug_spec.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "helpers")
|
2
|
-
require "sensu/extensions/handlers/debug"
|
3
|
-
|
4
|
-
describe "Sensu::Extension::Debug" do
|
5
|
-
include Helpers
|
6
|
-
|
7
|
-
before do
|
8
|
-
@extension = Sensu::Extension::Debug.new
|
9
|
-
end
|
10
|
-
|
11
|
-
it "can run, returning raw event data" do
|
12
|
-
event = {
|
13
|
-
:client => {},
|
14
|
-
:check => {
|
15
|
-
:output => "foo",
|
16
|
-
:status => 0
|
17
|
-
}
|
18
|
-
}
|
19
|
-
@extension.safe_run(event) do |output, status|
|
20
|
-
expect(output).to eq(event)
|
21
|
-
expect(status).to eq(0)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/spec/mutators/json_spec.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "helpers")
|
2
|
-
require "sensu/extensions/mutators/json"
|
3
|
-
|
4
|
-
describe "Sensu::Extension::Json" do
|
5
|
-
include Helpers
|
6
|
-
|
7
|
-
before do
|
8
|
-
@extension = Sensu::Extension::Json.new
|
9
|
-
end
|
10
|
-
|
11
|
-
it "can run, returning JSON event data" do
|
12
|
-
event = {
|
13
|
-
:client => {},
|
14
|
-
:check => {
|
15
|
-
:output => "foo",
|
16
|
-
:status => 0
|
17
|
-
}
|
18
|
-
}
|
19
|
-
@extension.safe_run(event) do |output, status|
|
20
|
-
expect(output).to eq(Sensu::JSON.dump(event))
|
21
|
-
expect(status).to eq(0)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "helpers")
|
2
|
-
require "sensu/extensions/mutators/only_check_output"
|
3
|
-
|
4
|
-
describe "Sensu::Extension::OnlyCheckOutput" do
|
5
|
-
include Helpers
|
6
|
-
|
7
|
-
before do
|
8
|
-
@extension = Sensu::Extension::OnlyCheckOutput.new
|
9
|
-
end
|
10
|
-
|
11
|
-
it "can run, returning only check output" do
|
12
|
-
event = {
|
13
|
-
:client => {},
|
14
|
-
:check => {
|
15
|
-
:output => "foo",
|
16
|
-
:status => 0
|
17
|
-
}
|
18
|
-
}
|
19
|
-
@extension.safe_run(event) do |output, status|
|
20
|
-
expect(output).to eq("foo")
|
21
|
-
expect(status).to eq(0)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "helpers")
|
2
|
-
require "sensu/extensions/mutators/ruby_hash"
|
3
|
-
|
4
|
-
describe "Sensu::Extension::RubyHash" do
|
5
|
-
include Helpers
|
6
|
-
|
7
|
-
before do
|
8
|
-
@extension = Sensu::Extension::RubyHash.new
|
9
|
-
end
|
10
|
-
|
11
|
-
it "can run, returning event data as a ruby hash" do
|
12
|
-
event = {
|
13
|
-
:client => {},
|
14
|
-
:check => {
|
15
|
-
:output => "foo",
|
16
|
-
:status => 0
|
17
|
-
}
|
18
|
-
}
|
19
|
-
@extension.safe_run(event) do |output, status|
|
20
|
-
expect(output).to eq(event)
|
21
|
-
expect(status).to eq(0)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|