sensu-plugins-zookeeper 1.4.0 → 1.5.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
- SHA1:
3
- metadata.gz: 50c001e82c65e3b2c3b2ef17bd5fe991baede851
4
- data.tar.gz: 6cf166d88e6baf96295af88f4dc4aca62281a172
2
+ SHA256:
3
+ metadata.gz: 730c88c962b31d3b0ca1ef65508e183a42ae62a4b08f237621af5e652decc9e8
4
+ data.tar.gz: 53eedd6d5defea10428b8c68bf28896578bb7b0e81545b3ed4e4f13a8ff56b7b
5
5
  SHA512:
6
- metadata.gz: cd99cd108966f6d63b95ea904d5c3b888ee68f821931445fe2a076f2c50ca9c85ba8d91fe0cc77c887e5b4b893b9e071a0e0a32ee73ce68645c59affbcfeacb8
7
- data.tar.gz: 8b74c06f883117c7db8278ce75b29535d89caf04a64c9940e6eacda87b1fad4bca896cd2a53177a542458145436587acecbd905bd51672386d735ddf7f288fc0
6
+ metadata.gz: 0042a27fd7df1d534ff063ed92f0b9c55248b3bc63332d0d4f1c85fd382801b97c4b79229916392a31fb59151b5549e34eebf478bee200348e2cf8c9fe3ab369
7
+ data.tar.gz: 9b3ec12a7481a6e2c203bc46154f523749290ab5da6f67c25bd7a5d182b92608a3ba5ac85ae74553df0f46e015fb281d8a2699d74c8758c22da701cd679e1763
@@ -6,6 +6,10 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.5.0] - 2017-12-06
10
+ ### Added
11
+ - check-netty-zookeeper-cluster.rb: new script to check if a zookeeper v. 3.5 cluster is OK (@duncaan)
12
+
9
13
  ## [1.4.0] - 2017-10-31
10
14
  ### Added
11
15
  - Added zookeeper port option to metrics-zookeeper-cluster.rb
@@ -67,7 +71,8 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
67
71
  ### Added
68
72
  - initial release
69
73
 
70
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/1.3.0...HEAD
74
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/1.5.0...HEAD
75
+ [1.5.0]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/1.4.0...1.5.0
71
76
  [1.4.0]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/1.3.0...1.4.0
72
77
  [1.3.0]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/1.2.0...1.3.0
73
78
  [1.2.0]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/1.1.0...1.2.0
data/README.md CHANGED
@@ -17,6 +17,7 @@
17
17
  * check-zookeeper-ruok.rb - Check if Zookeeper node responds to 'ruok' query succesfully
18
18
  * check-zookeeper-mode.rb - Check if Zookeeper node is in standalone or cluster(leader or follower) mode
19
19
  * check-zookeeper-cluster.rb - Check if a exhibitor managed Zookeeper cluster is OK.
20
+ * check-netty-zookeeper-cluster.rb - Check if a zookeeper 3.5 cluster is OK.
20
21
  * metrics-zookeeper.rb - Gather metrics from Zookeeper
21
22
  * metrics-zookeeper-cluster.rb - Gather metrics from An Exhibitor run Zookeeper cluster
22
23
 
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ #
5
+ # netty-check-zookeeper-cluster
6
+ #
7
+ # DESCRIPTION:
8
+ # Check if a Zookeeper 3.5 cluster is OK.
9
+ #
10
+ # This check will each verify each node for errors,
11
+ # check averag latency for a threshold value,
12
+ # and if the cluster has a leader, make sure it has the right number of followers.
13
+ #
14
+ # PLATFORMS:
15
+ # All
16
+ #
17
+ # DEPENDENCIES:
18
+ # gem: sensu-plugin
19
+ #
20
+ # USAGE:
21
+ # Check if a node has Zookeeper running and responds with imok.
22
+ #
23
+ # Cluster should have 3 (n+1) nodes and average latency threshold should be 10
24
+ # ./netty-check-zookeeeper-cluster.rb -c 2 -l 10
25
+ #
26
+ # LICENCE:
27
+ # Duncan Schulze <duschulze@gmail.com>
28
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
29
+ # for details.
30
+ #
31
+
32
+ require 'sensu-plugin/check/cli'
33
+ require 'net/http'
34
+ require 'json'
35
+
36
+ class CheckZookeeperCluster < Sensu::Plugin::Check::CLI
37
+ option :netty_port,
38
+ description: 'Zookeeper nodes\' listen port',
39
+ short: '-p port',
40
+ long: '--port port',
41
+ default: 8080,
42
+ proc: proc(&:to_i)
43
+
44
+ option :followers,
45
+ description: 'Zookeeper cluster follower count',
46
+ short: '-c count',
47
+ long: '--count count',
48
+ default: 2,
49
+ proc: proc(&:to_i)
50
+
51
+ option :latency,
52
+ description: 'Critical threshold for Zookeeper average latency',
53
+ short: '-l TICKS',
54
+ long: '--latency TICKS',
55
+ proc: proc(&:to_i),
56
+ default: 10
57
+
58
+ def get_monitoring_output(port)
59
+ uri = URI.parse("http://localhost:#{port}/commands/monitor")
60
+ http = Net::HTTP.new(uri.host, uri.port, read_timeout: 45)
61
+ http.read_timeout = 30
62
+ request = Net::HTTP::Get.new(uri.request_uri)
63
+ response = http.request(request)
64
+ JSON.parse(response.body)
65
+ rescue Errno::ECONNREFUSED
66
+ warning 'Connection refused'
67
+ rescue Timeout::Error
68
+ warning 'Connection timed out'
69
+ end
70
+
71
+ def are_you_ok
72
+ response = get_monitoring_output(config[:netty_port])
73
+ if response['error'].nil?
74
+ return { success: true,
75
+ message: 'Zookeeper is ok' }
76
+ else
77
+ return { success: false,
78
+ message: 'Zookeeper is not ok, look into the logs' }
79
+ end
80
+ end
81
+
82
+ def zookeeper_latency
83
+ response = get_monitoring_output(config[:netty_port])
84
+ if response['avg_latency'].to_i > config[:latecy].to_i
85
+ return { success: false,
86
+ message: %(Zookeeper latency is greater than #{config['latency']} seconds) }
87
+ else
88
+ return { success: true,
89
+ message: 'Zookeeper latency is ok' }
90
+ end
91
+ end
92
+
93
+ def follower_count
94
+ response = get_monitoring_output(config[:netty_port])
95
+ if response['server_state'].to_s == 'leader'
96
+ if response['synced_followers'].to_i == config[:followers].to_i
97
+ return { success: true,
98
+ message: 'Zookeeper follower count is correct' }
99
+ else
100
+ return { success: false,
101
+ message: %(Zookeeper follower count is not equal to #{config[:followers]}!) }
102
+ end
103
+ else
104
+ return { success: true,
105
+ message: 'Not the leader, follower check does not apply' }
106
+ end
107
+ end
108
+
109
+ def run
110
+ results = []
111
+ are_you_ok_result = are_you_ok
112
+ zookeeper_latency_result = zookeeper_latency
113
+ follower_count_result = follower_count
114
+
115
+ results.push(are_you_ok_result)
116
+ results.push(zookeeper_latency_result)
117
+ results.push(follower_count_result)
118
+
119
+ output = "SUCCESS: #{results.select { |h| h[:success] }.map { |h| h[:message] }}\n FAIL: #{results.reject { |h| h[:success] }.map { |h| h[:message] }}"
120
+
121
+ if results.any? { |h| !h[:success] }
122
+ warning output
123
+ else
124
+ ok output
125
+ end
126
+ end
127
+ end
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsZookeeper
2
2
  module Version
3
3
  MAJOR = 1
4
- MINOR = 4
4
+ MINOR = 5
5
5
  PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-zookeeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-31 00:00:00.000000000 Z
11
+ date: 2017-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -167,6 +167,7 @@ dependencies:
167
167
  description: Zookeeper plugins for checks and metrics
168
168
  email: "<sensu-users@googlegroups.com>"
169
169
  executables:
170
+ - check-netty-zookeeper-cluster.rb
170
171
  - check-znode.rb
171
172
  - check-zookeeper-cluster.rb
172
173
  - check-zookeeper-file-descriptors.rb
@@ -182,6 +183,7 @@ files:
182
183
  - CHANGELOG.md
183
184
  - LICENSE
184
185
  - README.md
186
+ - bin/check-netty-zookeeper-cluster.rb
185
187
  - bin/check-znode.rb
186
188
  - bin/check-zookeeper-cluster.rb
187
189
  - bin/check-zookeeper-file-descriptors.rb
@@ -217,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
219
  version: '0'
218
220
  requirements: []
219
221
  rubyforge_project:
220
- rubygems_version: 2.6.14
222
+ rubygems_version: 2.7.3
221
223
  signing_key:
222
224
  specification_version: 4
223
225
  summary: Sensu plugins for zookeeper