sensu-plugins-zookeeper 1.0.0 → 1.1.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: 6c0d590f718afae16c327b217c29af1cc1cb3c0c
4
- data.tar.gz: 722e665f154cf699c3340009c9cb5139b7ff591c
3
+ metadata.gz: 326e3e7e050ee97c7391843215f8222618cc3584
4
+ data.tar.gz: 3a8925749d5d0f87d6b14020b7ebca4608ef87c3
5
5
  SHA512:
6
- metadata.gz: 1003db56637f580411101624870281fe5a8985dd93fbf14e84335f872f9361dd132cf234da8a9248b6b86a23626081b50bd5cf74364c96fb2e4c4744a1b0cb1f
7
- data.tar.gz: c92d71c8e6b0ef00b6cde14b2899da445c65eb3422118c9d1d8dad6abeeda5a537d6357c9b3d385e4bdddf2d5c25684afc17c353588b02c4e7e00a405f3ba4d3
6
+ metadata.gz: f2db1a9a3a1315978de601fdffd92b2c4c52821a3a6be7795b9a02de02a5a08e76ee1bfcc3de5b119bf3f7789aa74a7e305fef99f9ccc069a7289f62a119421d
7
+ data.tar.gz: bfd3614b461395f46a35163c062394f0ea0926f1b6d544d02cc8a3753b9605f3b50886cd46532af1e189584488e8e4d592121f5064c5ad52cb2b319f38922a18
data/CHANGELOG.md CHANGED
@@ -5,6 +5,9 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [1.1.0] - 2017-03-23
9
+ - add `check-zookeeper-mode` to check if zookeeper is in the expected mode (@karthik-altiscale)
10
+
8
11
  ## [1.0.0] - 2017-03-21
9
12
  ### Added
10
13
  - check-zookeeper-reqs (@grem11n)
@@ -40,7 +43,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
40
43
  ### Added
41
44
  - initial release
42
45
 
43
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/1.0.0...HEAD
46
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/1.1.0...HEAD
47
+ [1.1.0]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/1.0.0...1.1.0
44
48
  [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/0.1.0...1.0.0
45
49
  [0.1.0]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/0.0.4...0.1.0
46
50
  [0.0.4]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/0.0.3...0.0.4
data/README.md CHANGED
@@ -15,6 +15,7 @@
15
15
  * check-zookeeper-latency.rb - Check average latency on Zookeeper node
16
16
  * check-zookeeper-reqs.rb - Check if Zookeeper node has reliable number of outstanding requests
17
17
  * check-zookeeper-ruok.rb - Check if Zookeeper node responds to 'ruok' query succesfully
18
+ * check-zookeeper-mode.rb - Check if Zookeeper node is in standalone or cluster(leader or follower) mode
18
19
  * metrics-zookeeper.rb - Gather metrics from Zookeeper
19
20
 
20
21
  ## Usage
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+ #
4
+ # check-zookeeper-mode
5
+ #
6
+ # DESCRIPTION:
7
+ # Check if Zookeeper node is in expected mode.
8
+ #
9
+ # 'mode' is ZooKeeper's mode which can be standalone or in a cluster.
10
+ # In cluster mode a Zookeeper node can be either leader or follower.
11
+ # We use stat command to get the mode and check if zookeeper node is a
12
+ # standalone or leader or follower.
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
+ # ./check-zookeeeper-mode.rb -m 'leader follower'
23
+ # ./check-zookeeeper-mode.rb -s localhost -p 2181 -m 'leader follower'
24
+ # ./check-zookeeeper-mode.rb --server localhost --port 2181 --mode 'leader follower'
25
+ #
26
+
27
+ require 'sensu-plugin/check/cli'
28
+ require 'socket'
29
+
30
+ class CheckZookeeperMode < Sensu::Plugin::Check::CLI
31
+ option :server,
32
+ description: 'Zookeeper hostname to connect to.',
33
+ short: '-s HOSTNAME',
34
+ long: '--server HOSTNAME',
35
+ default: 'localhost'
36
+
37
+ option :port,
38
+ description: 'Zookeeper port to connect to.',
39
+ short: '-p PORT',
40
+ long: '--port PORT',
41
+ default: 2181
42
+
43
+ option :timeout,
44
+ description: 'How long to wait for a reply in seconds.',
45
+ short: '-t SECS',
46
+ long: '--timeout SECS',
47
+ proc: proc(&:to_i),
48
+ default: 5
49
+
50
+ option :mode,
51
+ description: 'Space separated expected modes.',
52
+ short: '-m MODE',
53
+ long: '--mode MODE',
54
+ required: true
55
+
56
+ def zk_command(four_letter_word)
57
+ Socket.tcp(config[:server], config[:port]) do |sock|
58
+ sock.print "#{four_letter_word}\r\n"
59
+ sock.close_write
60
+ sock.read
61
+ end
62
+ end
63
+
64
+ def run
65
+ response = zk_command(:stat)
66
+ mode = get_mode(response)
67
+ expected_modes = config[:mode].split
68
+ if expected_modes.include?(mode)
69
+ ok(mode)
70
+ else
71
+ critical("Zookeeper mode is #{mode} and it does not match #{expected_modes.join(', ')}")
72
+ end
73
+ end
74
+
75
+ private
76
+
77
+ def get_mode(response)
78
+ response.each_line do |line|
79
+ line = line.chomp
80
+ k, v = line.split(': ')
81
+ return v if k == 'Mode'
82
+ end
83
+ end
84
+ end
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsZookeeper
2
2
  module Version
3
3
  MAJOR = 1
4
- MINOR = 0
4
+ MINOR = 1
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.0.0
4
+ version: 1.1.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-03-21 00:00:00.000000000 Z
11
+ date: 2017-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -170,6 +170,7 @@ executables:
170
170
  - check-znode.rb
171
171
  - check-zookeeper-file-descriptors.rb
172
172
  - check-zookeeper-latency.rb
173
+ - check-zookeeper-mode.rb
173
174
  - check-zookeeper-reqs.rb
174
175
  - check-zookeeper-ruok.rb
175
176
  - metrics-zookeeper.rb
@@ -182,6 +183,7 @@ files:
182
183
  - bin/check-znode.rb
183
184
  - bin/check-zookeeper-file-descriptors.rb
184
185
  - bin/check-zookeeper-latency.rb
186
+ - bin/check-zookeeper-mode.rb
185
187
  - bin/check-zookeeper-reqs.rb
186
188
  - bin/check-zookeeper-ruok.rb
187
189
  - bin/metrics-zookeeper.rb