From 16450be6e38813e63f2e5de2e31404c380292541 Mon Sep 17 00:00:00 2001 From: Olivier Bazoud Date: Fri, 10 Feb 2017 16:15:25 +0100 Subject: [PATCH] Add option to check topic's replicas --- CHANGELOG.md | 5 +++++ bin/check-topic.rb | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42e71c5..bf70648 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,11 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang ### Fixed ### Changed +## [Unreleased] + +### Added +- Add option to check topic's replicas + ## [0.6.1] - 2017-02-10 ### Fixed diff --git a/bin/check-topic.rb b/bin/check-topic.rb index 314dea4..71f83ca 100755 --- a/bin/check-topic.rb +++ b/bin/check-topic.rb @@ -62,6 +62,13 @@ class TopicsCheck < Sensu::Plugin::Check::CLI long: '--configs CONFIG', proc: proc { |a| JSON.parse(a) } + option :replicas, + description: 'Check replicats', + short: '-a', + long: '--replicas', + default: false, + boolean: false + option :leader, description: 'Check leader', short: '-l', @@ -89,6 +96,12 @@ def run critical "Topic '#{config[:name]}' RF is between #{min} and #{max}, expecting #{config[:replication_factor]}" if config[:replication_factor] != min || min != max end + if config[:replicas] + partitions.each do |num, replica| + critical "Topic '#{config[:name]}', partition #{num}: unknown replica #{replica - brokers}" unless (replica - brokers).empty? + end + end + if config[:leader] partitions.each do |num, replica| state_json = z.get(path: "/brokers/topics/#{config[:name]}/partitions/#{num}/state")[:data]