Skip to content

Commit

Permalink
Add option to check topic's replicas
Browse files Browse the repository at this point in the history
  • Loading branch information
obazoud committed Feb 10, 2017
1 parent d8c4186 commit 16450be
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions bin/check-topic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 16450be

Please sign in to comment.