sensu-plugins-kafka 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/bin/check-topic.rb +21 -3
- data/lib/sensu-plugins-kafka/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a203892a89baf95db18f62630db9ce83ed76a5a
|
4
|
+
data.tar.gz: 9afeed16635e6c99d5d648721e8e74a1503fb6f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0903a66748a37929ebc777caa3ae6bdb71d1a90a693bc9d29021a1caa1ea3dc201ce1f579199a49754c5af5b89193d231a153b6ed63de3590687fd689b7c58b8
|
7
|
+
data.tar.gz: 3b8d05e153fc34b370f278058bdd275b8d7a18ba8e402c7cfd63740b1882b6455556550139d4977360b735931d4137b24f339a0bea77e648b15c73ccfaf02318
|
data/CHANGELOG.md
CHANGED
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 { |_,
|
80
|
-
max = partitions.max_by { |_,
|
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}
|
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
|
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
|
+
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-
|
12
|
+
date: 2017-02-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sensu-plugin
|