sensu-plugins-kafka 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f15af24fc4ac6106a1ddee9d37d87199d837407b
4
- data.tar.gz: 29581c610cd42e174b6c0fe257ee7c59cf8142b6
3
+ metadata.gz: 0a203892a89baf95db18f62630db9ce83ed76a5a
4
+ data.tar.gz: 9afeed16635e6c99d5d648721e8e74a1503fb6f3
5
5
  SHA512:
6
- metadata.gz: f8933c4674ecbb29b96f1fe619793ee4e73027e82fe3f3c53711ed4c9c53e0eada1f53aa92298ba424b06b7a378bd97103999e51372845ba74db7dc21c0b530c
7
- data.tar.gz: 3fea1a9d4451727842d13c8189484307910c3376d1e60c656e8438328816077caa2a3aa69a6afd0a3eae98ead90809566cc669c515296e89bdaf5d9be1be30de
6
+ metadata.gz: 0903a66748a37929ebc777caa3ae6bdb71d1a90a693bc9d29021a1caa1ea3dc201ce1f579199a49754c5af5b89193d231a153b6ed63de3590687fd689b7c58b8
7
+ data.tar.gz: 3b8d05e153fc34b370f278058bdd275b8d7a18ba8e402c7cfd63740b1882b6455556550139d4977360b735931d4137b24f339a0bea77e648b15c73ccfaf02318
data/CHANGELOG.md CHANGED
@@ -10,6 +10,11 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
10
10
  ### Fixed
11
11
  ### Changed
12
12
 
13
+ ## [0.5.0] - 2017-02-09
14
+
15
+ ### Added
16
+ - Add option to check topic's leader
17
+
13
18
  ## [0.4.0] - 2017-02-09
14
19
 
15
20
  ### Added
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Sensu-Plugins-Kafka
2
2
 
3
- [![Build Status](https://travis-ci.org/obazoud/sensu-plugins-kafka.svg?branch=master)](https://travis-ci.org/obazoud/sensu-plugins-kafka)
3
+ [![Build Status](https://travis-ci.org/obazoud/sensu-plugins-kafka.svg?branch=master)](https://travis-ci.org/obazoud/sensu-plugins-kafka) [![Gem Version](https://badge.fury.io/rb/sensu-plugins-kafka.svg)](https://badge.fury.io/rb/sensu-plugins-kafka)
4
4
 
5
5
  ## Functionality
6
6
 
data/bin/check-topic.rb CHANGED
@@ -62,6 +62,13 @@ class TopicsCheck < Sensu::Plugin::Check::CLI
62
62
  long: '--configs CONFIG',
63
63
  proc: proc { |a| JSON.parse(a) }
64
64
 
65
+ option :leader,
66
+ description: 'Check leader',
67
+ short: '-l LEADER',
68
+ long: '--leader LEADER',
69
+ default: false,
70
+ boolean: false
71
+
65
72
  def run
66
73
  z = Zookeeper.new(config[:zookeeper])
67
74
 
@@ -70,24 +77,35 @@ class TopicsCheck < Sensu::Plugin::Check::CLI
70
77
  critical "Topic '#{config[:name]}' not found" unless topics.include? config[:name]
71
78
 
72
79
  if config.key?(:partitions) || config.key?(:replication_factor)
80
+ brokers = z.get_children(path: '/brokers/ids')[:children].map(&:to_i)
73
81
  partitions_data = z.get(path: "/brokers/topics/#{config[:name]}")[:data]
74
82
  partitions = JSON.parse(partitions_data)['partitions']
75
83
 
76
84
  critical "Topic '#{config[:name]}' has #{partitions.size} partitions, expecting #{config[:partitions]}" if config.key?(:partitions) && partitions.size != config[:partitions]
77
85
 
78
86
  if config.key?(:replication_factor)
79
- min = partitions.min_by { |_, brokers| brokers.size }[1].length
80
- max = partitions.max_by { |_, brokers| brokers.size }[1].length
87
+ min = partitions.min_by { |_, b| b.size }[1].length
88
+ max = partitions.max_by { |_, b| b.size }[1].length
81
89
  critical "Topic '#{config[:name]}' RF is between #{min} and #{max}, expecting #{config[:replication_factor]}" if config[:replication_factor] != min || min != max
82
90
  end
83
91
 
92
+ if config[:leader]
93
+ partitions.each do |num, replica|
94
+ state_json = z.get(path: "/brokers/topics/#{config[:name]}/partitions/#{num}/state")[:data]
95
+ state = JSON.parse(state_json)
96
+ critical "Topic '#{config[:name]}', unknown leader #{state['leader']}" unless brokers.include? state['leader']
97
+ critical "Topic '#{config[:name]}', partition #{num} preferred replica is not #{replica[0]}" unless replica[0] == state['leader']
98
+ end
99
+ end
100
+
84
101
  if config.key?(:configs)
85
102
  config_data = z.get(path: "/config/topics/#{config[:name]}")[:data]
86
103
  configs = JSON.parse(config_data)['config']
87
104
  config[:configs].each do |k, v|
88
- critical "Topic '#{config[:name]}': config #{k} is /#{v}, expecting #{configs[k]}" if !configs.key?(k) || configs[k].to_s != v.to_s
105
+ critical "Topic '#{config[:name]}': config #{k} = #{v}, expecting #{configs[k]}" if !configs.key?(k) || configs[k].to_s != v.to_s
89
106
  end
90
107
  end
108
+
91
109
  end
92
110
  ok
93
111
  rescue => e
@@ -5,7 +5,7 @@ module SensuPluginsKafka
5
5
  # This defines the version of the gem
6
6
  module Version
7
7
  MAJOR = 0
8
- MINOR = 4
8
+ MINOR = 5
9
9
  PATCH = 0
10
10
 
11
11
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-kafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - certs/sensu-plugins.pem
12
- date: 2017-02-09 00:00:00.000000000 Z
12
+ date: 2017-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sensu-plugin