sensu-plugins-kafka 0.2.1 → 0.3.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/bin/check-topic.rb +26 -2
- data/lib/sensu-plugins-kafka/version.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1e93ec2a07046094f7f0c1915b3b202743904694
|
|
4
|
+
data.tar.gz: 0c32ad6b95b36144ff864a9615cae8f8dc44186f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
-
|
|
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}"
|