sensu-plugins-zookeeper 1.3.0 → 3.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 72c0c089bdf151003b5f21a405e2fa917840ef76
4
- data.tar.gz: d3a5f610c72fb9d9ef6c331eacd18b2e584d4898
2
+ SHA256:
3
+ metadata.gz: fbff5ca8017a67540ee0e3460626562dd1e584aa882bbf1ecd5d16c7853528ef
4
+ data.tar.gz: 782756085bfbc2284ae6f9a2bd05346a8c984c2c28b3224f9975a3191bfb59c4
5
5
  SHA512:
6
- metadata.gz: 7ef6c1fdb309c82f192b9299f07f4423e5f5efa518411ca14e3ac4ab02868a6523f46c06ce1a3f233696f9c282a84a5519e7a0be6e357b77564e6202e1f07715
7
- data.tar.gz: 5816a75806675c37e4e155eb3dafbe80c3ea694769bd2b42460dd64cc09901f5fcf866d554e0b1808cd62175b15b2056b30a050208e110608aa99545c861a6cd
6
+ metadata.gz: 00c793488c17da38a9f7be98d49769a30eec26691f24a2439487b6964079dffa98697a27894494075fd8fb35753601904c8a39d35fc6d4f45d263fa050d8f587
7
+ data.tar.gz: c14da55994f9d5e221edf89278a94170eba0e5fa4acc15b4ec03b07595c4d68fd4b7fe4b3044f1621f66c7028335fc15112595c42554ee31e83bf935ec906e42
data/CHANGELOG.md CHANGED
@@ -6,6 +6,54 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [3.1.0] - 2021-03-31
10
+
11
+ ### Changes
12
+ - Use TCPSocket logic with timeout for check-zookeeper-mode.rb and metricz-zookepper.rb
13
+ - Update development_dependency: yard >= 0.9.20
14
+ - Remove CentOS 6 Asset build, CentOS6 reach end of life
15
+
16
+ ### Fixed
17
+ - Remove deplicate count option in check-zookeeper-cluster.rb
18
+
19
+ ## [3.0.0] - 2020-03-19
20
+ ### Breaking Changes
21
+ - Bump `sensu-plugin` dependency to `~> 4.0` you can read the changelog entries for [4.0](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#400---2018-02-17), [3.0](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#300---2018-12-04), and [2.0](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#v200---2017-03-29)
22
+ - Make minimum supported ruby version 2.3.0
23
+
24
+ ### Added
25
+ - Bonsai Asset enablement. Making changes to travis config to enable Bonsai asset building during release deployment
26
+
27
+ ### Changes
28
+ - Update development dependency: bundler ~> 2.1
29
+ - Update development dependency: codeclimate-test-reporter ~> 1.0
30
+ - Update development_dependency: github-markup ~> 3.0
31
+ - Update development_dependency: rake ~> 12.3
32
+
33
+ ### Fixed
34
+ - Updated how zookeeper information is scraped to use string matching instead of positional matching to accomedate newer zookeeper releases adding additional attributes.
35
+
36
+ ## [2.0.0] - 2018-01-18
37
+ ### Security
38
+ - updated rubocop dependency to `~> 0.51.0` per: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8418. (@thomasriley)
39
+
40
+ ### Breaking Changes
41
+ - removed < ruby 2.1 support which was pulled as part of security updates (@thomasriley)
42
+
43
+ ### Changed
44
+ - Various amendments to comply with Rubocop (@thomasriley)
45
+
46
+ ## [1.5.0] - 2017-12-06
47
+ ### Added
48
+ - check-netty-zookeeper-cluster.rb: new script to check if a zookeeper v. 3.5 cluster is OK (@duncaan)
49
+
50
+ ## [1.4.0] - 2017-10-31
51
+ ### Added
52
+ - Added zookeeper port option to metrics-zookeeper-cluster.rb
53
+
54
+ ### Fixed
55
+ - Fixed a return bug in case of an error on metrics-zookeeper-cluster.rb
56
+
9
57
  ## [1.3.0] - 2017-09-09
10
58
  ### Added
11
59
  - metrics-zookeeper-cluster.rb: new script to gather metrics from a zookeeper cluster (@fsniper)
@@ -60,7 +108,12 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
60
108
  ### Added
61
109
  - initial release
62
110
 
63
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/1.3.0...HEAD
111
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/3.1.0...HEAD
112
+ [3.1.0]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/3.0.0...3.1.0
113
+ [3.0.0]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/2.0.0...3.0.0
114
+ [2.0.0]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/1.5.0...2.0.0
115
+ [1.5.0]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/1.4.0...1.5.0
116
+ [1.4.0]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/1.3.0...1.4.0
64
117
  [1.3.0]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/1.2.0...1.3.0
65
118
  [1.2.0]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/1.1.0...1.2.0
66
119
  [1.1.0]: https://github.com/sensu-plugins/sensu-plugins-zookeeper/compare/1.0.0...1.1.0
data/README.md CHANGED
@@ -5,6 +5,10 @@
5
5
  [![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-zookeeper/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-zookeeper)
6
6
  [![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-zookeeper/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-zookeeper)
7
7
  [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-zookeeper.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-zookeeper)
8
+ [![Sensu Bonsai Asset](https://img.shields.io/badge/Bonsai-Download%20Me-brightgreen.svg?colorB=89C967&logo=sensu)](https://bonsai.sensu.io/assets/sensu-plugins/sensu-plugins-zookeeper)
9
+
10
+ ## Sensu Asset
11
+ The Sensu assets packaged from this repository are built against the Sensu Ruby runtime environment. When using these assets as part of a Sensu Go resource (check, mutator or handler), make sure you include the corresponding Sensu Ruby runtime asset in the list of assets needed by the resource. The current ruby-runtime assets can be found [here](https://bonsai.sensu.io/assets/sensu/sensu-ruby-runtime) in the [Bonsai Asset Index](bonsai.sensu.io).
8
12
 
9
13
  ## Functionality
10
14
 
@@ -17,10 +21,103 @@
17
21
  * check-zookeeper-ruok.rb - Check if Zookeeper node responds to 'ruok' query succesfully
18
22
  * check-zookeeper-mode.rb - Check if Zookeeper node is in standalone or cluster(leader or follower) mode
19
23
  * check-zookeeper-cluster.rb - Check if a exhibitor managed Zookeeper cluster is OK.
24
+ * check-netty-zookeeper-cluster.rb - Check if a zookeeper 3.5 cluster is OK.
20
25
  * metrics-zookeeper.rb - Gather metrics from Zookeeper
21
26
  * metrics-zookeeper-cluster.rb - Gather metrics from An Exhibitor run Zookeeper cluster
22
27
 
23
28
  ## Usage
29
+ ```
30
+ $ check-znode.rb --help
31
+ Usage: ./bin/check-znode.rb (options)
32
+ -v, --check_value REGEX Optionally check the znode value against a regex
33
+ -s, --servers zk-address zk address to connect to (required)
34
+ -z, --znode ZNODE znode to check (required)
35
+ ```
36
+
37
+ ```
38
+ $ check-zookeeper-file-descriptors.rb --help
39
+ Usage: ./bin/check-zookeeper-file-descriptors.rb (options)
40
+ -d DESCRIPTORS, Critical threshold for Zookeeper open files descriptors
41
+ --file-descriptors
42
+ -p, --port PORT Zookeeper port to connect to.
43
+ -s, --server HOSTNAME Zookeeper hostname to connect to.
44
+ -t, --timeout SECS How long to wait for a reply in seconds.
45
+
46
+ ```
47
+
48
+ ```
49
+ $ check-zookeeper-cluster.rb --help
50
+ Usage: ./bin/check-zookeeper-cluster.rb (options)
51
+ -c, --count count Zookeeper cluster node count
52
+ -e, --exhibitor status end point exhibitor end node for status checks
53
+ -l, --latency TICKS Critical threshold for Zookeeper average latency
54
+ -t, --timeout SECS How long to wait for a reply in seconds.
55
+ -p, --port port Zookeeper nodes' listen port
56
+
57
+ ```
58
+
59
+ ```
60
+ $ check-netty-zookeeper-cluster.rb --help
61
+ Usage: ./bin/check-netty-zookeeper-cluster.rb (options)
62
+ -c, --count count Zookeeper cluster follower count
63
+ -l, --latency TICKS Critical threshold for Zookeeper average latency
64
+ -p, --port port Zookeeper nodes' listen port
65
+
66
+ ```
67
+
68
+ ```
69
+ $ metrics-zookeeper.rb --help
70
+ Usage: ./bin/metrics-zookeeper.rb (options)
71
+ --host HOST ZooKeeper host
72
+ --port PORT ZooKeeper port
73
+ --scheme SCHEME Metric naming scheme, text to prepend to metrics
74
+
75
+ ```
76
+
77
+ ```
78
+ $ metrics-zookeeper-cluster.rb --help
79
+ Usage: ./bin/metrics-zookeeper-cluster.rb (options)
80
+ -e, --exhibitor status end point exhibitor end node for status checks
81
+ --scheme SCHEME Metric naming scheme, text to prepend to metrics
82
+ -p, --port port Zookeeper nodes' listen port
83
+
84
+ ```
85
+
86
+ ```
87
+ $ check-zookeeper-ruok.rb --help
88
+ Usage: ./bin/check-zookeeper-ruok.rb (options)
89
+ -p, --port PORT Zookeeper port to connect to.
90
+ -s, --server HOSTNAME Zookeeper hostname to connect to.
91
+ -t, --timeout SECS How long to wait for a reply in seconds.
92
+ ```
93
+
94
+ ```
95
+ $ check-zookeeper-reqs.rb --help
96
+ Usage: ./bin/check-zookeeper-reqs.rb (options)
97
+ -r, --reqs REQS Critical threshold for Zookeeper outstanding requests
98
+ -p, --port PORT Zookeeper port to connect to.
99
+ -s, --server HOSTNAME Zookeeper hostname to connect to.
100
+ -t, --timeout SECS How long to wait for a reply in seconds.
101
+ ```
102
+
103
+ ```
104
+ $ check-zookeeper-mode.rb --help
105
+ Usage check-zookeeper-mode.rb (options)
106
+ -m, --mode MODE Space separated expected modes. (required)
107
+ -p, --port PORT Zookeeper port to connect to.
108
+ -s, --server HOSTNAME Zookeeper hostname to connect to.
109
+ -t, --timeout SECS How long to wait for a reply in seconds.
110
+ ```
111
+
112
+ ```
113
+ $ check-zookeeper-latency.rb --help
114
+ Usage: ./bin/check-zookeeper-latency.rb (options)
115
+ -l, --latency TICKS Critical threshold for Zookeeper average latency
116
+ -p, --port PORT Zookeeper port to connect to.
117
+ -s, --server HOSTNAME Zookeeper hostname to connect to.
118
+ -t, --timeout SECS How long to wait for a reply in seconds.
119
+
120
+ ```
24
121
 
25
122
  ## Installation
26
123
 
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #
4
+ # netty-check-zookeeper-cluster
5
+ #
6
+ # DESCRIPTION:
7
+ # Check if a Zookeeper 3.5 cluster is OK.
8
+ #
9
+ # This check will each verify each node for errors,
10
+ # check averag latency for a threshold value,
11
+ # and if the cluster has a leader, make sure it has the right number of followers.
12
+ #
13
+ # PLATFORMS:
14
+ # All
15
+ #
16
+ # DEPENDENCIES:
17
+ # gem: sensu-plugin
18
+ #
19
+ # USAGE:
20
+ # Check if a node has Zookeeper running and responds with imok.
21
+ #
22
+ # Cluster should have 3 (n+1) nodes and average latency threshold should be 10
23
+ # ./netty-check-zookeeeper-cluster.rb -c 2 -l 10
24
+ #
25
+ # LICENCE:
26
+ # Duncan Schulze <duschulze@gmail.com>
27
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
28
+ # for details.
29
+ #
30
+
31
+ require 'sensu-plugin/check/cli'
32
+ require 'net/http'
33
+ require 'json'
34
+
35
+ class CheckZookeeperCluster < Sensu::Plugin::Check::CLI
36
+ option :netty_port,
37
+ description: 'Zookeeper nodes\' listen port',
38
+ short: '-p port',
39
+ long: '--port port',
40
+ default: 8080,
41
+ proc: proc(&:to_i)
42
+
43
+ option :followers,
44
+ description: 'Zookeeper cluster follower count',
45
+ short: '-c count',
46
+ long: '--count count',
47
+ default: 2,
48
+ proc: proc(&:to_i)
49
+
50
+ option :latency,
51
+ description: 'Critical threshold for Zookeeper average latency',
52
+ short: '-l TICKS',
53
+ long: '--latency TICKS',
54
+ proc: proc(&:to_i),
55
+ default: 10
56
+
57
+ def get_monitoring_output(port)
58
+ uri = URI.parse("http://localhost:#{port}/commands/monitor")
59
+ http = Net::HTTP.new(uri.host, uri.port, read_timeout: 45)
60
+ http.read_timeout = 30
61
+ request = Net::HTTP::Get.new(uri.request_uri)
62
+ response = http.request(request)
63
+ JSON.parse(response.body)
64
+ rescue Errno::ECONNREFUSED
65
+ warning 'Connection refused'
66
+ rescue Timeout::Error
67
+ warning 'Connection timed out'
68
+ end
69
+
70
+ def are_you_ok
71
+ response = get_monitoring_output(config[:netty_port])
72
+ if response['error'].nil?
73
+ return { success: true,
74
+ message: 'Zookeeper is ok' }
75
+ else
76
+ return { success: false,
77
+ message: 'Zookeeper is not ok, look into the logs' }
78
+ end
79
+ end
80
+
81
+ def zookeeper_latency
82
+ response = get_monitoring_output(config[:netty_port])
83
+ if response['avg_latency'].to_i > config[:latecy].to_i
84
+ return { success: false,
85
+ message: %(Zookeeper latency is greater than #{config['latency']} seconds) }
86
+ else
87
+ return { success: true,
88
+ message: 'Zookeeper latency is ok' }
89
+ end
90
+ end
91
+
92
+ def follower_count
93
+ response = get_monitoring_output(config[:netty_port])
94
+ if response['server_state'].to_s == 'leader'
95
+ if response['synced_followers'].to_i == config[:followers].to_i
96
+ return { success: true,
97
+ message: 'Zookeeper follower count is correct' }
98
+ else
99
+ return { success: false,
100
+ message: %(Zookeeper follower count is not equal to #{config[:followers]}!) }
101
+ end
102
+ else
103
+ return { success: true,
104
+ message: 'Not the leader, follower check does not apply' }
105
+ end
106
+ end
107
+
108
+ def run
109
+ results = []
110
+ are_you_ok_result = are_you_ok
111
+ zookeeper_latency_result = zookeeper_latency
112
+ follower_count_result = follower_count
113
+
114
+ results.push(are_you_ok_result)
115
+ results.push(zookeeper_latency_result)
116
+ results.push(follower_count_result)
117
+
118
+ output = "SUCCESS: #{results.select { |h| h[:success] }.map { |h| h[:message] }}\n FAIL: #{results.reject { |h| h[:success] }.map { |h| h[:message] }}"
119
+
120
+ if results.any? { |h| !h[:success] }
121
+ warning output
122
+ else
123
+ ok output
124
+ end
125
+ end
126
+ end
data/bin/check-znode.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  #! /usr/bin/env ruby
2
- # encoding: UTF-8
3
2
  #
4
3
  # check-znode
5
4
  #
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
2
  #
4
3
  # check-zookeeper-cluster
5
4
  #
@@ -45,13 +44,6 @@ class CheckZookeeperCluster < Sensu::Plugin::Check::CLI
45
44
  default: 2181,
46
45
  proc: proc(&:to_i)
47
46
 
48
- option :count,
49
- description: 'Zookeeper cluster node count',
50
- short: '-c count',
51
- long: '--count count',
52
- default: 3,
53
- proc: proc(&:to_i)
54
-
55
47
  option :exhibitor,
56
48
  description: 'exhibitor end node for status checks',
57
49
  short: '-e Exhibitor status end point',
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
2
  #
4
3
  # check-zookeeper-file-descriptors.rb
5
4
  #
@@ -71,7 +70,7 @@ class CheckZookeeperREQS < Sensu::Plugin::Check::CLI
71
70
  end
72
71
 
73
72
  result = ready.first.first.read.chomp.split("\n")
74
- avg_fd = (result[13].split("\t")[1].to_f / result[14].split("\t")[1].to_f)
73
+ avg_fd = (result.grep(/zk_open_file_descriptor_count/)[0].split("\t")[1].to_f / result.grep(/zk_max_file_descriptor_count/)[0].split("\t")[1].to_f)
75
74
 
76
75
  ok %(Zookeeper's open file descriptors rate is #{avg_fd}) if avg_fd < config[:fd_critical]
77
76
  critical %(Zookeeper's open file descriptors rate is #{avg_fd}, which is more than #{config[:fd_critical]} threshold)
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
2
  #
4
3
  # check-zookeeper-latency
5
4
  #
@@ -68,7 +67,7 @@ class CheckZookeeperREQS < Sensu::Plugin::Check::CLI
68
67
  end
69
68
 
70
69
  result = ready.first.first.read.chomp.split("\n")
71
- avg_latency = result[1].split("\t")[1].to_i
70
+ avg_latency = result.grep(/zk_avg_latency/)[0].split("\t")[1].to_i
72
71
 
73
72
  ok %(Zookeeper has average latency #{avg_latency}) if avg_latency < config[:avg_latency_critical]
74
73
  critical %(Zookeeper's average latency is #{avg_latency}, which is more than #{config[:avg_latency_critical]} threshold)
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
2
  #
4
3
  # check-zookeeper-mode
5
4
  #
@@ -54,10 +53,16 @@ class CheckZookeeperMode < Sensu::Plugin::Check::CLI
54
53
  required: true
55
54
 
56
55
  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
56
+ TCPSocket.open(config[:server], config[:port]) do |socket|
57
+ socket.write four_letter_word.to_s
58
+ ready = IO.select([socket], nil, nil, config[:timeout])
59
+
60
+ if ready.nil?
61
+ critical %(Zookeeper did not respond to #{four_letter_word} within #{config[:timeout]} seconds)
62
+ end
63
+
64
+ result = ready.first.first.read.chomp
65
+ return result
61
66
  end
62
67
  end
63
68
 
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
2
  #
4
3
  # check-zookeeper-reqs
5
4
  #
@@ -71,7 +70,7 @@ class CheckZookeeperREQS < Sensu::Plugin::Check::CLI
71
70
  end
72
71
 
73
72
  result = ready.first.first.read.chomp.split("\n")
74
- out_reqs = result[7].split("\t")[1].to_i
73
+ out_reqs = result.grep(/zk_outstanding_requests/)[0].split("\t")[1].to_i
75
74
 
76
75
  ok %(Zookeeper has #{out_reqs} outstanding requests) if out_reqs < config[:out_reqs_critical]
77
76
  critical %(Zookeeper has #{out_reqs} outstanding requests, which is more than #{config[:out_reqs_critical]} threshold)
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
2
  #
4
3
  # check-zookeeper-ruok
5
4
  #
@@ -25,6 +25,7 @@
25
25
  #
26
26
 
27
27
  require 'sensu-plugin/metric/cli'
28
+ require 'sensu-plugins-zookeeper/version'
28
29
  require 'socket'
29
30
  require 'net/http'
30
31
  require 'json'
@@ -41,7 +42,17 @@ class ZookeeperMetrics < Sensu::Plugin::Metric::CLI::Graphite
41
42
  long: '--scheme SCHEME',
42
43
  default: 'zookeeper'
43
44
 
44
- def follow_url(uri_str, agent = "sensu-plugins-zookeeper/#{SensuPluginsZookeeper::Version::VER_STRING}", max_attempts = 10, timeout = 10)
45
+ option :zk_port,
46
+ description: 'Zookeeper nodes\' listen port',
47
+ short: '-p port',
48
+ long: '--port port',
49
+ default: 2181,
50
+ proc: proc(&:to_i)
51
+
52
+ def follow_url(uri_str,
53
+ agent = "sensu-plugins-zookeeper/#{SensuPluginsZookeeper::Version::VER_STRING}",
54
+ max_attempts = 10,
55
+ timeout = 10)
45
56
  attempts = 0
46
57
  cookie = nil
47
58
 
@@ -87,6 +98,7 @@ class ZookeeperMetrics < Sensu::Plugin::Metric::CLI::Graphite
87
98
 
88
99
  response
89
100
  end
101
+ # rubocop:enable Style/CommentedKeyword
90
102
 
91
103
  def dotted(*args)
92
104
  args.join('.')
@@ -102,7 +114,7 @@ class ZookeeperMetrics < Sensu::Plugin::Metric::CLI::Graphite
102
114
 
103
115
  def exhibitor_status
104
116
  response = follow_url(config[:exhibitor])
105
- JSON.parse(response.body)
117
+ json = JSON.parse(response.body)
106
118
  rescue StandardError => e
107
119
  [false, json, ['exhibitor status is not http 200 ' + e.message]]
108
120
  end
@@ -111,9 +123,11 @@ class ZookeeperMetrics < Sensu::Plugin::Metric::CLI::Graphite
111
123
  timestamp = Time.now.to_i
112
124
 
113
125
  json = exhibitor_status
114
- json.each do |zk|
126
+
127
+ # TODO: Need to shortern this function
128
+ json.each do |zk| # rubocop:disable Metrics/BlockLength
115
129
  hostname = zk['hostname']
116
- response = zk_command(:mntr, hostname, 2181)
130
+ response = zk_command(:mntr, hostname, config[:zk_port])
117
131
  metrics = {}
118
132
 
119
133
  if response =~ /^zk_avg_latency\s*(\d+)$/
@@ -38,6 +38,13 @@ class ZookeeperMetrics < Sensu::Plugin::Metric::CLI::Graphite
38
38
  proc: proc(&:to_i),
39
39
  default: 2181
40
40
 
41
+ option :timeout,
42
+ description: 'How long to wait for a reply in seconds.',
43
+ short: '-t SECS',
44
+ long: '--timeout SECS',
45
+ proc: proc(&:to_i),
46
+ default: 5
47
+
41
48
  option :scheme,
42
49
  description: 'Metric naming scheme, text to prepend to metrics',
43
50
  long: '--scheme SCHEME',
@@ -48,10 +55,15 @@ class ZookeeperMetrics < Sensu::Plugin::Metric::CLI::Graphite
48
55
  end
49
56
 
50
57
  def zk_command(four_letter_word)
51
- Socket.tcp(config[:host], config[:port]) do |sock|
52
- sock.print "#{four_letter_word}\r\n"
53
- sock.close_write
54
- sock.read
58
+ TCPSocket.open(config[:server], config[:port]) do |socket|
59
+ socket.write four_letter_word.to_s
60
+ ready = IO.select([socket], nil, nil, config[:timeout])
61
+
62
+ if ready.nil?
63
+ critical %(Zookeeper did not respond to '#{four_letter_word}' within #{config[:timeout]} seconds)
64
+ end
65
+ result = ready.first.first.read.chomp
66
+ return result
55
67
  end
56
68
  end
57
69
 
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsZookeeper
2
2
  module Version
3
- MAJOR = 1
4
- MINOR = 3
3
+ MAJOR = 3
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.3.0
4
+ version: 3.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-09-09 00:00:00.000000000 Z
11
+ date: 2021-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.2'
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.2'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: zookeeper
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,42 +44,42 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.7'
47
+ version: '2.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.7'
54
+ version: '2.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: codeclimate-test-reporter
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.4'
61
+ version: '1.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.4'
68
+ version: '1.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: github-markup
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.3'
75
+ version: '3.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.3'
82
+ version: '3.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: pry
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '10.5'
103
+ version: '12.3'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '10.5'
110
+ version: '12.3'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: redcarpet
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -123,65 +123,67 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '3.2'
125
125
  - !ruby/object:Gem::Dependency
126
- name: rubocop
126
+ name: rspec
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.40.0
131
+ version: '3.4'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 0.40.0
138
+ version: '3.4'
139
139
  - !ruby/object:Gem::Dependency
140
- name: rspec
140
+ name: rubocop
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '3.4'
145
+ version: 0.51.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '3.4'
152
+ version: 0.51.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: yard
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '0.8'
159
+ version: 0.9.20
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '0.8'
166
+ version: 0.9.20
167
167
  description: Zookeeper plugins for checks and metrics
168
168
  email: "<sensu-users@googlegroups.com>"
169
169
  executables:
170
- - check-znode.rb
171
- - check-zookeeper-cluster.rb
170
+ - metrics-zookeeper.rb
171
+ - check-zookeeper-mode.rb
172
172
  - check-zookeeper-file-descriptors.rb
173
+ - metrics-zookeeper-cluster.rb
174
+ - check-znode.rb
175
+ - check-zookeeper-ruok.rb
173
176
  - check-zookeeper-latency.rb
174
- - check-zookeeper-mode.rb
175
177
  - check-zookeeper-reqs.rb
176
- - check-zookeeper-ruok.rb
177
- - metrics-zookeeper-cluster.rb
178
- - metrics-zookeeper.rb
178
+ - check-netty-zookeeper-cluster.rb
179
+ - check-zookeeper-cluster.rb
179
180
  extensions: []
180
181
  extra_rdoc_files: []
181
182
  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
@@ -209,15 +211,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
209
211
  requirements:
210
212
  - - ">="
211
213
  - !ruby/object:Gem::Version
212
- version: 2.0.0
214
+ version: 2.3.0
213
215
  required_rubygems_version: !ruby/object:Gem::Requirement
214
216
  requirements:
215
217
  - - ">="
216
218
  - !ruby/object:Gem::Version
217
219
  version: '0'
218
220
  requirements: []
219
- rubyforge_project:
220
- rubygems_version: 2.6.13
221
+ rubygems_version: 3.0.8
221
222
  signing_key:
222
223
  specification_version: 4
223
224
  summary: Sensu plugins for zookeeper