Skip to content

Commit

Permalink
Improve chek-broker
Browse files Browse the repository at this point in the history
  • Loading branch information
obazoud committed Dec 23, 2018
1 parent 7a23d6c commit 1859f38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions bin/check-broker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#

require 'sensu-plugin/check/cli'
require 'json'
require 'zookeeper'

class BrokerCheck < Sensu::Plugin::Check::CLI
Expand All @@ -45,12 +44,18 @@ class BrokerCheck < Sensu::Plugin::Check::CLI
proc: proc { |a| a.split(',') },
required: true

option :size,
description: 'Broker size',
short: '-s BROKER_SIZE',
long: '--broker-size BROKER_SIZE',
proc: proc(&:to_i)
def run
z = Zookeeper.new(config[:zookeeper])

brokers = z.get(path: '/brokers')[:data]
brokers = z.get_children(path: '/brokers/ids')[:children]

critical "Broker '#{brokers}' not found"
critical "Broker '#{config[:ids] - brokers}' not found" unless (config[:ids] - brokers).length == 0
critical "Broker wrong size: #{brokers.length} (#{brokers}), expection #{config[:size]}" unless brokers.length == config[:size]

ok
rescue => e
Expand Down
4 changes: 2 additions & 2 deletions sensu-plugins-kafka.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'zookeeper', '~> 1.4.11'

s.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
s.add_development_dependency 'rubocop', '0.32.1'
s.add_development_dependency 'rubocop', '0.49.0'
s.add_development_dependency 'rspec', '~> 3.1'
s.add_development_dependency 'bundler', '~> 1.7'
s.add_development_dependency 'rake', '~> 10.0'
s.add_development_dependency 'github-markup', '~> 1.3'
s.add_development_dependency 'redcarpet', '~> 3.2'
s.add_development_dependency 'yard', '~> 0.8'
s.add_development_dependency 'yard', '~> 0.9.11'
s.add_development_dependency 'pry', '~> 0.10'
end

0 comments on commit 1859f38

Please sign in to comment.