sensu-plugins-kafka 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10e9d48ba8a90c446cc5ba9b82d027e6fb55ddfc
4
- data.tar.gz: bdd9251b41653a0a990a68b199bac4aba92b53ce
3
+ metadata.gz: 1e93ec2a07046094f7f0c1915b3b202743904694
4
+ data.tar.gz: 0c32ad6b95b36144ff864a9615cae8f8dc44186f
5
5
  SHA512:
6
- metadata.gz: 6227b504aeaccb43e9ae87bba56e1f86508d2376c76022d1ee20c0237c762aad8a74fdcfc09923ef7625b72edadbb959fa02b3269810e5e64e79982a9847a9f5
7
- data.tar.gz: 78da58aad700bda5ad6a8e656d5451360188303d0cd6e2b93fcb8f4ea1efb32f83c8f1887086d37e217ce14708a961da97c7d633ba70d9e848bc51948062b3c4
6
+ metadata.gz: 1911daa3cc089954f3e3042110bae2a7ca6e42443841d77f6f46ba02120d12f7ef8f98d9478edef0246019be592c8c2172d3704844a33dad192f63a8b8f7d9df
7
+ data.tar.gz: 9a683432a3fb1d69b0e840c8b629b40e37962cf964ca3ff13df6ce3e8f227c9a3bd8284f69823a2081454bb143d7af94245d1098f73ba1651170485ac9e8c128
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.3.0] - 2017-02-09
14
+
15
+ ### Added
16
+ - check-topic.rb: option to check partitions and replication factor
17
+
13
18
  ## [0.2.0] - 2017-02-09
14
19
 
15
20
  ### Breaking Changes
data/bin/check-topic.rb CHANGED
@@ -44,13 +44,37 @@ class TopicsCheck < Sensu::Plugin::Check::CLI
44
44
  long: '--name TOPIC_NAME',
45
45
  required: true
46
46
 
47
+ option :partitions,
48
+ description: 'Partitions',
49
+ short: '-p PARTITIONS_COUNT',
50
+ long: '--partitions TOPIC_NAME',
51
+ proc: proc(&:to_i)
52
+
53
+ option :replication_factor,
54
+ description: 'Replication factor',
55
+ short: '-r REPLICATION_FACTOR',
56
+ long: '--replication-factor REPLICATION_FACTOR',
57
+ proc: proc(&:to_i)
58
+
47
59
  def run
48
60
  z = Zookeeper.new(config[:zookeeper])
49
61
 
50
- live_topics = z.get_children(path: '/brokers/topics')[:children].sort
62
+ topics = z.get_children(path: '/brokers/topics')[:children].sort
63
+
64
+ critical "Topic '#{config[:name]}' not found" unless topics.include? config[:name]
65
+
66
+ if config.key?(:partitions) || config.key?(:replication_factor)
67
+ partitions_data = z.get(path: "/brokers/topics/#{config[:name]}")[:data]
68
+ partitions = JSON.parse(partitions_data)['partitions']
51
69
 
52
- critical "#{config[:name]} not found" unless live_topics.include? config[:name]
70
+ critical "Topic '#{config[:name]}' has #{partitions.size} partitions, expecting #{config[:partitions]}" if config.key?(:partitions) && partitions.size != config[:partitions]
53
71
 
72
+ if config.key?(:replication_factor)
73
+ min = partitions.min_by { |_, brokers| brokers.size }[1].length
74
+ max = partitions.max_by { |_, brokers| brokers.size }[1].length
75
+ critical "Topic '#{config[:name]}' RF is between #{min} and #{max}, expecting #{config[:replication_factor]}" if config[:replication_factor] != min || min != max
76
+ end
77
+ end
54
78
  ok
55
79
  rescue => e
56
80
  puts "Error: #{e.backtrace}"
@@ -5,8 +5,8 @@ module SensuPluginsKafka
5
5
  # This defines the version of the gem
6
6
  module Version
7
7
  MAJOR = 0
8
- MINOR = 2
9
- PATCH = 1
8
+ MINOR = 3
9
+ PATCH = 0
10
10
 
11
11
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
12
12
  end
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.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors