sensu-extensions 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.travis.yml +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +20 -0
- data/README.md +28 -0
- data/Rakefile +6 -0
- data/lib/sensu/extensions.rb +29 -0
- data/lib/sensu/extensions/handlers/debug.rb +19 -0
- data/lib/sensu/extensions/loader.rb +135 -0
- data/lib/sensu/extensions/mutators/only_check_output.rb +19 -0
- data/sensu-extensions.gemspec +25 -0
- data/spec/assets/extensions/error.rb +17 -0
- data/spec/assets/extensions/test.rb +17 -0
- data/spec/extensions_spec.rb +46 -0
- data/spec/handlers/debug_spec.rb +24 -0
- data/spec/helpers.rb +29 -0
- data/spec/loader_spec.rb +79 -0
- data/spec/mutators/only_check_output_spec.rb +24 -0
- metadata +153 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 921d30c624c871a29bdebaffbb2a6ad90e534c14
|
4
|
+
data.tar.gz: 65287442e82d713e383b0b029121ddfc37dfd4fe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 90ad3a3900709a313464058d508dd928fcb0197eebbb137e1977cd4e4d28ee7b77868963bff68929a783868fb813102be6357c6c292ba9079b72de69855fc5b6
|
7
|
+
data.tar.gz: 15e88aed2126991161ae87abaf0951692b5ddc220a7a761fe9dee9c0e1fd583b0e7d94379e30c562287c8a0d871e7528595171a2bcd68db3070e66c48162b944
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 Heavy Water Operations, LLC.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Sensu::Extensions
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/sensu/sensu-extensions.svg?branch=master)](https://travis-ci.org/sensu/sensu-extensions)
|
4
|
+
|
5
|
+
[![Code Climate](https://codeclimate.com/github/sensu/sensu-extensions.png)](https://codeclimate.com/github/sensu/sensu-extensions)
|
6
|
+
[![Code Climate Coverage](https://codeclimate.com/github/sensu/sensu-extensions/coverage.png)](https://codeclimate.com/github/sensu/sensu-extensions)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'sensu-extensions'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
Documentation can be found [here](http://rubydoc.info/github/sensu/sensu-extensions/Sensu/Extensions).
|
21
|
+
|
22
|
+
## Contributing
|
23
|
+
|
24
|
+
1. [Fork it](https://github.com/sensu/sensu-extensions/fork)
|
25
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
26
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
27
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
28
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "sensu/extensions/loader"
|
2
|
+
|
3
|
+
module Sensu
|
4
|
+
module Extensions
|
5
|
+
# Load Sensu extensions.
|
6
|
+
#
|
7
|
+
# @param [Hash] options
|
8
|
+
# @option options [String] :extension_file to load.
|
9
|
+
# @option options [String] :extension_dir to load.
|
10
|
+
# @option options [Array] :extension_dirs to load.
|
11
|
+
# @return [Loader] a loaded instance of Loader.
|
12
|
+
def self.load(options={})
|
13
|
+
loader = Loader.new
|
14
|
+
if options[:extension_file]
|
15
|
+
loader.load_file(options[:extension_file])
|
16
|
+
end
|
17
|
+
if options[:extension_dir]
|
18
|
+
loader.load_directory(options[:extension_dir])
|
19
|
+
end
|
20
|
+
if options[:extension_dirs]
|
21
|
+
options[:extension_dirs].each do |directory|
|
22
|
+
loader.load_directory(directory)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
loader.load_instances
|
26
|
+
loader
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "sensu/extension"
|
2
|
+
|
3
|
+
module Sensu
|
4
|
+
module Extension
|
5
|
+
class Debug < Handler
|
6
|
+
def name
|
7
|
+
"debug"
|
8
|
+
end
|
9
|
+
|
10
|
+
def description
|
11
|
+
"returns inspected event data"
|
12
|
+
end
|
13
|
+
|
14
|
+
def run(event)
|
15
|
+
yield event.inspect, 0
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
require "sensu/extension"
|
2
|
+
require "sensu/extensions/mutators/only_check_output"
|
3
|
+
require "sensu/extensions/handlers/debug"
|
4
|
+
|
5
|
+
module Sensu
|
6
|
+
module Extensions
|
7
|
+
class Loader
|
8
|
+
# @!attribute [r] warnings
|
9
|
+
# @return [Array] loader warnings.
|
10
|
+
attr_reader :warnings
|
11
|
+
|
12
|
+
# @!attribute [r] loaded_files
|
13
|
+
# @return [Array] loaded extension files.
|
14
|
+
attr_reader :loaded_files
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@warnings = []
|
18
|
+
@loaded_files = []
|
19
|
+
@extensions = {}
|
20
|
+
Extension::CATEGORIES.each do |category|
|
21
|
+
@extensions[category] = {}
|
22
|
+
end
|
23
|
+
self.class.create_category_methods
|
24
|
+
end
|
25
|
+
|
26
|
+
# Create extension category accessors and methods to test the
|
27
|
+
# existence of extensions. Called in initialize().
|
28
|
+
def self.create_category_methods
|
29
|
+
Extension::CATEGORIES.each do |category|
|
30
|
+
define_method(category) do
|
31
|
+
extension_category(category)
|
32
|
+
end
|
33
|
+
method_name = category.to_s.chop + "_exists?"
|
34
|
+
define_method(method_name.to_sym) do |name|
|
35
|
+
extension_exists?(category, name)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Retrieve the extension object corresponding to a key, acting
|
41
|
+
# like a Hash object.
|
42
|
+
#
|
43
|
+
# @param key [Symbol]
|
44
|
+
# @return [Object] value for key.
|
45
|
+
def [](key)
|
46
|
+
@extensions[key]
|
47
|
+
end
|
48
|
+
|
49
|
+
# Retrieve all extension instances.
|
50
|
+
#
|
51
|
+
# @return [Array<object>] extensions.
|
52
|
+
def all
|
53
|
+
@extensions.map { |category, extensions|
|
54
|
+
extensions.map do |name, extension|
|
55
|
+
extension
|
56
|
+
end
|
57
|
+
}.flatten
|
58
|
+
end
|
59
|
+
|
60
|
+
# Load an extension from a file.
|
61
|
+
#
|
62
|
+
# @param [String] file path.
|
63
|
+
def load_file(file)
|
64
|
+
warning("loading extension file", :file => file)
|
65
|
+
begin
|
66
|
+
require File.expand_path(file)
|
67
|
+
@loaded_files << file
|
68
|
+
rescue ScriptError, StandardError => error
|
69
|
+
warning("failed to require extension", :file => file, :error => error)
|
70
|
+
warning("ignoring extension", :file => file)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Load extensions from files in a directory. Files may be in
|
75
|
+
# nested directories.
|
76
|
+
#
|
77
|
+
# @param [String] directory path.
|
78
|
+
def load_directory(directory)
|
79
|
+
warning("loading extension files from directory", :directory => directory)
|
80
|
+
path = directory.gsub(/\\(?=\S)/, "/")
|
81
|
+
Dir.glob(File.join(path, "**/*.rb")).each do |file|
|
82
|
+
load_file(file)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Load instances of the loaded extensions.
|
87
|
+
def load_instances
|
88
|
+
Extension::CATEGORIES.each do |category|
|
89
|
+
extension_type = category.to_s.chop
|
90
|
+
Extension.const_get(extension_type.capitalize).descendants.each do |klass|
|
91
|
+
extension = klass.new
|
92
|
+
@extensions[category][extension.name] = extension
|
93
|
+
warning("loaded extension", {
|
94
|
+
:type => extension_type,
|
95
|
+
:name => extension.name,
|
96
|
+
:description => extension.description
|
97
|
+
})
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
# Retrieve extension category definitions.
|
105
|
+
#
|
106
|
+
# @param [Symbol] category to retrive.
|
107
|
+
# @return [Array<Hash>] category definitions.
|
108
|
+
def extension_category(category)
|
109
|
+
@extensions[category].map do |name, extension|
|
110
|
+
extension.definition
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Check to see if an extension exists in a category.
|
115
|
+
#
|
116
|
+
# @param [Symbol] category to inspect for the extension.
|
117
|
+
# @param [String] name of extension.
|
118
|
+
# @return [TrueClass, FalseClass]
|
119
|
+
def extension_exists?(category, name)
|
120
|
+
@extensions[category].has_key?(name)
|
121
|
+
end
|
122
|
+
|
123
|
+
# Record a warning.
|
124
|
+
#
|
125
|
+
# @param message [String] warning message.
|
126
|
+
# @param data [Hash] warning context.
|
127
|
+
# @return [Array] current warnings.
|
128
|
+
def warning(message, data={})
|
129
|
+
@warnings << {
|
130
|
+
:message => message
|
131
|
+
}.merge(data)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,19 @@
|
|
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
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "sensu-extensions"
|
5
|
+
spec.version = "0.0.1"
|
6
|
+
spec.authors = ["Sean Porter"]
|
7
|
+
spec.email = ["portertech@gmail.com"]
|
8
|
+
spec.summary = "The Sensu extension loader library"
|
9
|
+
spec.description = "The Sensu extension loader library"
|
10
|
+
spec.homepage = "https://github.com/sensu/sensu-extensions"
|
11
|
+
spec.license = "MIT"
|
12
|
+
|
13
|
+
spec.files = `git ls-files -z`.split("\x0")
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
|
18
|
+
spec.add_dependency "sensu-em"
|
19
|
+
spec.add_dependency "sensu-extension"
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "codeclimate-test-reporter"
|
25
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "helpers")
|
2
|
+
require "sensu/extensions"
|
3
|
+
|
4
|
+
describe "Sensu::Extensions" do
|
5
|
+
include Helpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@assets_dir = File.join(File.dirname(__FILE__), "assets")
|
9
|
+
@extension_dir = File.join(@assets_dir, "extensions")
|
10
|
+
@extension_file = File.join(@extension_dir, "test.rb")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "can provide the extensions API" do
|
14
|
+
Sensu::Extensions.should respond_to(:load)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "can provide an instance of Loader" do
|
18
|
+
extensions = Sensu::Extensions.load
|
19
|
+
extensions.should be_instance_of(Sensu::Extensions::Loader)
|
20
|
+
extensions.loaded_files.should be_empty
|
21
|
+
end
|
22
|
+
|
23
|
+
it "can load an extension from a file" do
|
24
|
+
extensions = Sensu::Extensions.load(:extension_file => @extension_file)
|
25
|
+
extensions.loaded_files.size.should eq(1)
|
26
|
+
extensions.handler_exists?("test").should be_true
|
27
|
+
end
|
28
|
+
|
29
|
+
it "can load extensions from a directory" do
|
30
|
+
extensions = Sensu::Extensions.load(:extension_dir => @extension_dir)
|
31
|
+
extensions.loaded_files.size.should eq(1)
|
32
|
+
extensions.handler_exists?("test").should be_true
|
33
|
+
end
|
34
|
+
|
35
|
+
it "can load extensions from one or more directories" do
|
36
|
+
extensions = Sensu::Extensions.load(:extension_dirs => [@extension_dir])
|
37
|
+
extensions.loaded_files.size.should eq(1)
|
38
|
+
extensions.handler_exists?("test").should be_true
|
39
|
+
end
|
40
|
+
|
41
|
+
it "can load the built-in extensions" do
|
42
|
+
extensions = Sensu::Extensions.load
|
43
|
+
extensions.mutator_exists?("only_check_output").should be_true
|
44
|
+
extensions.handler_exists?("debug").should be_true
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,24 @@
|
|
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 an inspected 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
|
+
output.should eq(event.inspect)
|
21
|
+
status.should eq(0)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/helpers.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "rspec"
|
2
|
+
require "eventmachine"
|
3
|
+
|
4
|
+
unless RUBY_VERSION < "1.9" || RUBY_PLATFORM =~ /java/
|
5
|
+
require "codeclimate-test-reporter"
|
6
|
+
CodeClimate::TestReporter.start
|
7
|
+
end
|
8
|
+
|
9
|
+
module Helpers
|
10
|
+
def timer(delay, &callback)
|
11
|
+
periodic_timer = EM::PeriodicTimer.new(delay) do
|
12
|
+
callback.call
|
13
|
+
periodic_timer.cancel
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def async_wrapper(&callback)
|
18
|
+
EM.run do
|
19
|
+
timer(10) do
|
20
|
+
raise "test timed out"
|
21
|
+
end
|
22
|
+
callback.call
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def async_done
|
27
|
+
EM.stop_event_loop
|
28
|
+
end
|
29
|
+
end
|
data/spec/loader_spec.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "helpers")
|
2
|
+
require "sensu/extensions/loader"
|
3
|
+
|
4
|
+
describe "Sensu::Extensions::Loader" do
|
5
|
+
include Helpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@loader = Sensu::Extensions::Loader.new
|
9
|
+
@assets_dir = File.join(File.dirname(__FILE__), "assets")
|
10
|
+
@extension_dir = File.join(@assets_dir, "extensions")
|
11
|
+
@extension_file = File.join(@extension_dir, "test.rb")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "can provide the extensions loader API" do
|
15
|
+
@loader.should respond_to(:load_file, :load_directory, :load_instances,
|
16
|
+
:warnings, :loaded_files, :[], :all,
|
17
|
+
:generics, :bridges, :checks, :mutators, :handlers)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "can load an extension from a file" do
|
21
|
+
@loader.load_file(@extension_file)
|
22
|
+
@loader.warnings.size.should eq(1)
|
23
|
+
@loader.loaded_files.size.should eq(1)
|
24
|
+
@loader.loaded_files.first.should eq(File.expand_path(@extension_file))
|
25
|
+
extension = Sensu::Extension::Test.new
|
26
|
+
extension.should respond_to(:name, :description, :definition, :safe_run, :stop, :has_key?, :[])
|
27
|
+
end
|
28
|
+
|
29
|
+
it "can attempt to load an extension with a script error" do
|
30
|
+
script = File.join(@extension_dir, "error.rb")
|
31
|
+
@loader.load_file(script)
|
32
|
+
warnings = @loader.warnings
|
33
|
+
warnings.size.should eq(3)
|
34
|
+
messages = warnings.map do |warning|
|
35
|
+
warning[:message]
|
36
|
+
end
|
37
|
+
messages.should include("loading extension file")
|
38
|
+
messages.should include("ignoring extension")
|
39
|
+
@loader.loaded_files.should be_empty
|
40
|
+
end
|
41
|
+
|
42
|
+
it "can load extensions from a directory" do
|
43
|
+
@loader.load_directory(@extension_dir)
|
44
|
+
@loader.warnings.size.should eq(5)
|
45
|
+
@loader.loaded_files.size.should eq(1)
|
46
|
+
extension = Sensu::Extension::Test.new
|
47
|
+
extension.should respond_to(:name, :description, :definition, :safe_run, :stop, :has_key?, :[])
|
48
|
+
end
|
49
|
+
|
50
|
+
it "can attempt to load extensions from a nonexistent directory" do
|
51
|
+
@loader.load_directory("/tmp/bananaphone")
|
52
|
+
@loader.warnings.size.should eq(1)
|
53
|
+
@loader.loaded_files.should be_empty
|
54
|
+
end
|
55
|
+
|
56
|
+
it "can load instances of the built-in extensions and provide accessors" do
|
57
|
+
@loader.load_instances
|
58
|
+
@loader.handler_exists?("debug").should be_true
|
59
|
+
extension = @loader[:handlers]["debug"]
|
60
|
+
extension.should be_instance_of(Sensu::Extension::Debug)
|
61
|
+
extension.should respond_to(:name, :description, :definition, :safe_run, :stop, :has_key?, :[])
|
62
|
+
@loader.handlers.should include(extension.definition)
|
63
|
+
@loader.all.should include(extension)
|
64
|
+
@loader.mutator_exists?("only_check_output").should be_true
|
65
|
+
end
|
66
|
+
|
67
|
+
it "can load instances of the built-in and loaded extensions" do
|
68
|
+
@loader.load_file(@extension_file)
|
69
|
+
@loader.load_instances
|
70
|
+
@loader.handler_exists?("test").should be_true
|
71
|
+
extension = @loader[:handlers]["test"]
|
72
|
+
extension.should be_instance_of(Sensu::Extension::Test)
|
73
|
+
extension.should respond_to(:name, :description, :definition, :safe_run, :stop, :has_key?, :[])
|
74
|
+
@loader.handlers.should include(extension.definition)
|
75
|
+
@loader.all.should include(extension)
|
76
|
+
@loader.handler_exists?("debug").should be_true
|
77
|
+
@loader.mutator_exists?("only_check_output").should be_true
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,24 @@
|
|
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
|
+
output.should eq("foo")
|
21
|
+
status.should eq(0)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-extensions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sean Porter
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sensu-em
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sensu-extension
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: codeclimate-test-reporter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: The Sensu extension loader library
|
98
|
+
email:
|
99
|
+
- portertech@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- lib/sensu/extensions.rb
|
111
|
+
- lib/sensu/extensions/handlers/debug.rb
|
112
|
+
- lib/sensu/extensions/loader.rb
|
113
|
+
- lib/sensu/extensions/mutators/only_check_output.rb
|
114
|
+
- sensu-extensions.gemspec
|
115
|
+
- spec/assets/extensions/error.rb
|
116
|
+
- spec/assets/extensions/test.rb
|
117
|
+
- spec/extensions_spec.rb
|
118
|
+
- spec/handlers/debug_spec.rb
|
119
|
+
- spec/helpers.rb
|
120
|
+
- spec/loader_spec.rb
|
121
|
+
- spec/mutators/only_check_output_spec.rb
|
122
|
+
homepage: https://github.com/sensu/sensu-extensions
|
123
|
+
licenses:
|
124
|
+
- MIT
|
125
|
+
metadata: {}
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 2.2.0
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: The Sensu extension loader library
|
146
|
+
test_files:
|
147
|
+
- spec/assets/extensions/error.rb
|
148
|
+
- spec/assets/extensions/test.rb
|
149
|
+
- spec/extensions_spec.rb
|
150
|
+
- spec/handlers/debug_spec.rb
|
151
|
+
- spec/helpers.rb
|
152
|
+
- spec/loader_spec.rb
|
153
|
+
- spec/mutators/only_check_output_spec.rb
|