sensu-plugins-kafka 0.8.1 → 0.9.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 +8 -3
- data/README.md +3 -3
- data/bin/metrics-consumer.rb +38 -45
- 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: 0a503a49eba3fdde83ea058f05aa528e880e88d3
|
4
|
+
data.tar.gz: 987863996d1810bb470709f75141a9f6e5c6d752
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b48c13220791bec9f7d77e9502865bb208c91cc1767fb70788baa13a4329d05bb17449979ab76c39ded7e5f92666900945c86d59e04cd0e1927f0315d921aabc
|
7
|
+
data.tar.gz: 04d858babaebd2080e08adc7e0d34a879a384ea3899bea6b6e1c8e374e5dda15340df03606d7575da410342dc61325fa8e8b8d6df5673c73d1294a2a89a9de2d
|
data/CHANGELOG.md
CHANGED
@@ -10,17 +10,22 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
10
10
|
### Fixed
|
11
11
|
### Changed
|
12
12
|
|
13
|
-
## [0.
|
13
|
+
## [0.9.0] - 2017-02-16
|
14
|
+
|
15
|
+
### Breaking Changes
|
16
|
+
- Refactoring metrics-consumer-lag to remove shell/jvm execution
|
17
|
+
|
18
|
+
## [0.8.1] - 2017-02-16
|
14
19
|
|
15
20
|
### Fixed
|
16
21
|
- check-consumer-lag: remove celluloid (temporary), fix data structure, fix partition_owner function
|
17
22
|
|
18
|
-
## [0.8.0]
|
23
|
+
## [0.8.0] - 2017-02-15
|
19
24
|
|
20
25
|
### Breaking Changes
|
21
26
|
- Refactoring check-consumer-lag to remove shell/jvm execution
|
22
27
|
|
23
|
-
## [0.7.0]
|
28
|
+
## [0.7.0] - 2017-02-10
|
24
29
|
|
25
30
|
### Added
|
26
31
|
- Add option to check topic's replicas
|
data/README.md
CHANGED
@@ -20,8 +20,8 @@
|
|
20
20
|
|
21
21
|
[Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
Kafka version: 0.8.2.x
|
23
|
+
Tested on:
|
24
|
+
* Zookeeper version: 3.4.6
|
25
|
+
* Kafka version: 0.8.2.x
|
26
26
|
|
27
27
|
Note: In addition to the standard installation requirements the installation of this gem will require compiling the nokogiri gem. Due to this you'll need certain developmemnt packages on your system. On Ubuntu systems install build-essential, libxml2-dev and zlib1g-dev. On CentOS install gcc and zlib-devel.
|
data/bin/metrics-consumer.rb
CHANGED
@@ -26,6 +26,10 @@
|
|
26
26
|
|
27
27
|
require 'sensu-plugin/metric/cli'
|
28
28
|
|
29
|
+
require 'json'
|
30
|
+
require 'poseidon'
|
31
|
+
require 'zookeeper'
|
32
|
+
|
29
33
|
class ConsumerOffsetMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
30
34
|
option :scheme,
|
31
35
|
description: 'Metric naming scheme, text to prepend to metric',
|
@@ -39,12 +43,6 @@ class ConsumerOffsetMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
39
43
|
long: '--group NAME',
|
40
44
|
required: true
|
41
45
|
|
42
|
-
option :kafka_home,
|
43
|
-
description: 'Kafka home',
|
44
|
-
short: '-k NAME',
|
45
|
-
long: '--kafka-home NAME',
|
46
|
-
default: '/opt/kafka'
|
47
|
-
|
48
46
|
option :topic,
|
49
47
|
description: 'Comma-separated list of consumer topics',
|
50
48
|
short: '-t NAME',
|
@@ -62,51 +60,46 @@ class ConsumerOffsetMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
62
60
|
long: '--zookeeper NAME',
|
63
61
|
default: 'localhost:2181'
|
64
62
|
|
65
|
-
|
66
|
-
|
67
|
-
def read_lines(cmd)
|
68
|
-
IO.popen(cmd + ' 2>&1') do |child|
|
69
|
-
child.read.split("\n")
|
70
|
-
end
|
71
|
-
end
|
63
|
+
def run
|
64
|
+
z = Zookeeper.new(config[:zookeeper])
|
72
65
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
66
|
+
group = config[:group]
|
67
|
+
topics = kafka_topics(z, group)
|
68
|
+
|
69
|
+
critical 'Could not found topics' if topics.empty?
|
70
|
+
|
71
|
+
consumers = {}
|
72
|
+
topics.each do |topic|
|
73
|
+
consumers[topic] = []
|
74
|
+
|
75
|
+
topics_partitions(z, topic).each do |partition|
|
76
|
+
leader = leader_broker(z, topic, partition)
|
77
|
+
consumer = Poseidon::PartitionConsumer.new('CheckConsumerLag', leader['host'], leader['port'], topic, partition, :latest_offset)
|
78
|
+
logsize = consumer.next_offset
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
offset = consumer_offset(z, group, topic, partition)
|
81
|
+
|
82
|
+
lag = logsize - offset
|
83
|
+
consumers[topic].push(partition: partition, logsize: logsize, offset: offset, lag: lag)
|
84
|
+
end
|
85
85
|
end
|
86
|
-
end
|
87
86
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
Hash[k, v.inject(0) { |a, e| a + e[field].to_i }]
|
101
|
-
end
|
102
|
-
sum_by_group.delete_if { |x| config[:topic_excludes].include?(x.keys[0]) } if config[:topic_excludes]
|
103
|
-
sum_by_group.each do |x|
|
104
|
-
output "#{config[:scheme]}.#{config[:group]}.#{x.keys[0]}.#{field}", x.values[0]
|
105
|
-
end
|
87
|
+
[:offset, :logsize, :lag].each do |field|
|
88
|
+
consumers.each do |k, v|
|
89
|
+
critical "Topic #{k} has #{field} < 0 '#{v[field]}'" unless v.select { |w| w[field].to_i < 0 }.empty?
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
[:offset, :logsize, :lag].each do |field|
|
94
|
+
sum_by_group = consumers.map do |k, v|
|
95
|
+
Hash[k, v.inject(0) { |a, e| a + e[field].to_i }]
|
96
|
+
end
|
97
|
+
sum_by_group.each do |x|
|
98
|
+
output "#{config[:scheme]}.#{config[:group]}.#{x.keys[0]}.#{field}", x.values[0]
|
106
99
|
end
|
107
|
-
rescue => e
|
108
|
-
critical "Error: exception: #{e}"
|
109
100
|
end
|
110
101
|
ok
|
102
|
+
rescue => e
|
103
|
+
critical "Error: exception: #{e}"
|
111
104
|
end
|
112
105
|
end
|