From 1859f3893607b3679dcac37682fefedcee3e5e27 Mon Sep 17 00:00:00 2001 From: Olivier Bazoud Date: Sun, 23 Dec 2018 10:51:51 +0100 Subject: [PATCH] Improve chek-broker --- bin/check-broker.rb | 11 ++++++++--- sensu-plugins-kafka.gemspec | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/bin/check-broker.rb b/bin/check-broker.rb index f9b7672..96ebb14 100755 --- a/bin/check-broker.rb +++ b/bin/check-broker.rb @@ -27,7 +27,6 @@ # require 'sensu-plugin/check/cli' -require 'json' require 'zookeeper' class BrokerCheck < Sensu::Plugin::Check::CLI @@ -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 diff --git a/sensu-plugins-kafka.gemspec b/sensu-plugins-kafka.gemspec index 152edba..d44566d 100644 --- a/sensu-plugins-kafka.gemspec +++ b/sensu-plugins-kafka.gemspec @@ -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