-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move duplicated code to libraries (#71)
* Add plugin stub for tests * Add tests for queue metrics * Add tests for exchange metrics * Add tests for queue check * Add base class for metrics (#65) * Add common check class * Move common options into a module * Common rabbitmq_info getter * Fix Rubocop offenses * Split module and classes in separate files * Update Changelog * Remove require_relative * Use ruby_dig for older rubies
- Loading branch information
1 parent
dea41d4
commit 2c5f865
Showing
13 changed files
with
469 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
require 'ruby_dig' | ||
|
||
require 'sensu-plugins-rabbitmq/version' | ||
require 'sensu-plugins-rabbitmq/check' | ||
require 'sensu-plugins-rabbitmq/metrics' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'sensu-plugin/check/cli' | ||
require 'sensu-plugins-rabbitmq/rabbitmq' | ||
|
||
module Sensu | ||
module Plugin | ||
module RabbitMQ | ||
class Check < Sensu::Plugin::Check::CLI | ||
include Sensu::Plugin::RabbitMQ::Common | ||
|
||
# To avoid complaints from mother class at the end of tests (at_exit handler) | ||
def run | ||
ok | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'sensu-plugin/metric/cli' | ||
require 'socket' | ||
require 'sensu-plugins-rabbitmq/rabbitmq' | ||
|
||
module Sensu | ||
module Plugin | ||
module RabbitMQ | ||
class Metrics < Sensu::Plugin::Metric::CLI::Graphite | ||
include Sensu::Plugin::RabbitMQ::Common | ||
|
||
option :scheme, | ||
description: 'Metric naming scheme', | ||
long: '--scheme SCHEME', | ||
default: "#{Socket.gethostname}.rabbitmq" | ||
|
||
def dotted_keys(hash, prefix = '', keys = []) | ||
hash.each do |k, v| | ||
if v.is_a? Hash | ||
keys = dotted_keys(v, prefix + k + '.', keys) | ||
else | ||
keys << prefix + k | ||
end | ||
end | ||
keys | ||
end | ||
|
||
# To avoid complaints from mother class at the end of tests (at_exit handler) | ||
def run | ||
ok | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.