sensu-plugins-edgelab 1.11.1 → 1.13.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
2
  SHA1:
3
- metadata.gz: 076e6c8bad29dc55ffbbf4cd72b7710db3bcdd30
4
- data.tar.gz: 8ec7646f4e8c12d9ad42a93f92b942bc1666b477
3
+ metadata.gz: 87437ac974abcfec419ece3cac1c136fc20088f5
4
+ data.tar.gz: 43d43f8faf3f56528b456a2144ee5a9e877d78c4
5
5
  SHA512:
6
- metadata.gz: 224e41e898131c46a28a10630281ffb05cc7ea73725893ab4930c0fc5822ac9fbe288c25e1353c9b81b62767bf0265ca14a53e56ae28ea8281fe7ffa7c565f46
7
- data.tar.gz: 9bc8214833cc511c8911fbdc373e80ceb087a61c7f3f0e4b9e923135ed815b3ec9a1e721a17cefd16cd1cec5ea21941610f296704d52030ff2e0866685dcc7e9
6
+ metadata.gz: dc630eb477e2dc478e07195efbe88a293e84e27814a3d716004c99ab983b5de3245c60ae6a1aaac50819130438e6dda13e6fbeda3e3679a9bcf94879b2dba574
7
+ data.tar.gz: 8c05803ae96c6fad066fd85524a27b66301e19673c0eadbc92fad2f87ba1c878810fc7992a8f7aac620fe369def9cc5f57f73e6694c84ed7dbf6f3d311c3ca41
@@ -0,0 +1,119 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-cassandra-schema
4
+ #
5
+ # DESCRIPTION:
6
+ # This plugin uses Apache Cassandra's `nodetool` to see if any node in the
7
+ # cluster are not in the correct state.
8
+ #
9
+ # OUTPUT:
10
+ # plain text
11
+ #
12
+ # PLATFORMS:
13
+ # Linux
14
+ #
15
+ # DEPENDENCIES:
16
+ # gem: sensu-plugin
17
+ # gem: english
18
+ # Cassandra's nodetool
19
+ #
20
+ # LICENSE:
21
+ # Copyright 2017 Jonathan Ballet <jballet@edgelab.ch>
22
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
23
+ # for details.
24
+ #
25
+
26
+ require 'sensu-plugin/check/cli'
27
+ require 'English'
28
+
29
+ #
30
+ # Check Cassandra Node
31
+ #
32
+ class CheckCassandraNode < Sensu::Plugin::Check::CLI
33
+ option :hostname,
34
+ short: '-h HOSTNAME',
35
+ long: '--host HOSTNAME',
36
+ description: 'cassandra hostname',
37
+ default: 'localhost'
38
+
39
+ option :port,
40
+ short: '-P PORT',
41
+ long: '--port PORT',
42
+ description: 'cassandra JMX port',
43
+ default: '7199'
44
+
45
+ # Execute Cassandra's 'nodetool' and return output as string
46
+ def nodetool_cmd(cmd)
47
+ out = `nodetool -h #{config[:hostname]} -p #{config[:port]} #{cmd} 2>&1`
48
+ [out, $CHILD_STATUS]
49
+ end
50
+
51
+ def run
52
+ out, rc = nodetool_cmd('status')
53
+ if rc != 0
54
+ puts rc
55
+ critical(out)
56
+ end
57
+
58
+ error_nodes = []
59
+ warning_nodes = []
60
+ ok_nodes = []
61
+
62
+ total_load = 0
63
+ nodes = {}
64
+
65
+ out.each_line do |line|
66
+ if m = line.match(/^([UD])([NLJM])\s+([0-9\.]+)\s+([0-9\.]+) ([a-zA-Z]+)\s+([0-9]+).*\s+([^ ]+)$/) # rubocop:disable all
67
+ status = m[1]
68
+ state = m[2]
69
+ address = m[3]
70
+ load_ = m[4]
71
+ unit = m[5]
72
+ rack = m[6]
73
+
74
+ factor = 1
75
+ if unit == 'GiB'
76
+ factor = 1024 * 1024 * 1024
77
+ elsif unit == 'MiB'
78
+ factor = 1024 * 1024
79
+ elsif unit == 'KiB'
80
+ factor = 1024
81
+ end
82
+
83
+ nodes[address] = {
84
+ status: status,
85
+ state: state,
86
+ load: (load_.to_f * factor),
87
+ rack: rack
88
+ }
89
+ total_load += nodes[address][:load]
90
+ end
91
+ end
92
+
93
+ nodes.each do |address, node|
94
+ if node[:status] != 'U'
95
+ error_nodes << "Node #{address} is Down #{node[:status]}"
96
+ next
97
+ end
98
+
99
+ if node[:state] == 'J'
100
+ # TODO: is that interesting to have?
101
+ # content = 100 * node[:load] / total_load
102
+ # ideal = 100 / nodes.count
103
+ # warning_nodes << "#{address} is joining (has #{content.round(1)}%, ideal=#{ideal.round(1)}%)"
104
+ warning_nodes << "#{address} is joining"
105
+ next
106
+ end
107
+
108
+ ok_nodes << "#{address} is normal (#{node[:status]}#{node[:state]})"
109
+ end
110
+
111
+ if error_nodes.count > 0
112
+ criticial error_nodes.join(', ')
113
+ elsif warning_nodes.count > 0
114
+ warning warning_nodes.join(', ')
115
+ else
116
+ ok ok_nodes.join(', ')
117
+ end
118
+ end
119
+ end
@@ -91,7 +91,7 @@ class CheckLogstashPipeline < Sensu::Plugin::Check::CLI
91
91
  socket.puts(JSON.generate(msg))
92
92
  socket.close
93
93
 
94
- msearch1 = {index: ["logstash-*"]}
94
+ msearch1 = { index: ['logstash-*'] }
95
95
  msearch2 = {
96
96
  size: 5,
97
97
  query: {
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # metrics-cassandra-basic
4
+ #
5
+ # DESCRIPTION:
6
+ # Get basic metrics about a Cassandra cluster
7
+ #
8
+ # OUTPUT:
9
+ # metric data
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: sensu-plugin
16
+ # gem: cassandra
17
+ #
18
+ # USAGE:
19
+ # #YELLOW
20
+ #
21
+ # NOTES:
22
+ #
23
+ # LICENSE:
24
+ # Copyright 2018 EdgeLaboratories.
25
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
26
+ # for details.
27
+ #
28
+
29
+ require 'sensu-plugin/metric/cli'
30
+ require 'socket'
31
+ require 'cassandra'
32
+
33
+ #
34
+ # Cassandra Basic Metrics
35
+ #
36
+ class CassandraBasicMetrics < Sensu::Plugin::Metric::CLI::Graphite
37
+ option :hostname,
38
+ short: '-h HOSTNAME',
39
+ long: '--host HOSTNAME',
40
+ description: 'Cassandra hostname',
41
+ default: 'localhost'
42
+
43
+ option :port,
44
+ short: '-P PORT',
45
+ long: '--port PORT',
46
+ description: 'Cassandra CQL port',
47
+ default: 9042
48
+
49
+ option :scheme,
50
+ description: 'Metric naming scheme, text to prepend to metric',
51
+ short: '-s SCHEME',
52
+ long: '--scheme SCHEME',
53
+ default: "#{Socket.gethostname}.cassandra-cluster"
54
+
55
+ def safe_name(name)
56
+ name.gsub!(/[^a-zA-Z0-9]/, '_') # convert all other chars to _
57
+ name.gsub!(/[_]*$/, '') # remove any _'s at end of the string
58
+ name.gsub!(/[_]{2,}/, '_') # convert sequence of multiple _'s to single _
59
+ name
60
+ end
61
+
62
+ def connect
63
+ @cluster = Cassandra.cluster(
64
+ hosts: [config[:hostname]],
65
+ port: config[:port],
66
+ )
67
+ end
68
+
69
+ def parse_keyspace
70
+ output "#{config[:scheme]}.#{safe_name(@cluster.name)}.nodes.count", @cluster.hosts.length, @timestamp
71
+ output "#{config[:scheme]}.#{safe_name(@cluster.name)}.keyspaces.count", @cluster.keyspaces.length, @timestamp
72
+
73
+ session = @cluster.connect('system_schema')
74
+ cf = session.execute('SELECT table_name FROM tables')
75
+ output "#{config[:scheme]}.#{safe_name(@cluster.name)}.column_families.count", cf.length, @timestamp
76
+ end
77
+
78
+ def run
79
+ @timestamp = Time.now.to_i
80
+
81
+ connect
82
+ parse_keyspace
83
+
84
+ ok
85
+ end
86
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-edgelab
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.1
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgelab
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-30 00:00:00.000000000 Z
11
+ date: 2018-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '2.3'
111
+ - !ruby/object:Gem::Dependency
112
+ name: cassandra-driver
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 3.2.2
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 3.2.2
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: bundler
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -153,22 +167,25 @@ dependencies:
153
167
  description: Sensu plugins developed by Edgelab
154
168
  email:
155
169
  executables:
156
- - metrics-aws-asg.rb
157
- - metrics-redis-key-pattern.rb
158
- - check-apt-expired-keys.rb
159
- - check-swarm-cluster.rb
160
- - metrics-aws-elb.rb
170
+ - check-nomad-leader.rb
171
+ - metrics-es-indices.rb
161
172
  - check-consul-services.rb
173
+ - check-nomad-jobs.rb
162
174
  - metrics-aws-rds.rb
163
- - metrics-es-indices.rb
164
- - check-nomad-leader.rb
175
+ - check-apt-expired-keys.rb
165
176
  - metrics-swarm-cluster.rb
177
+ - check-swarm-cluster.rb
178
+ - metrics-cassandra-basic.rb
179
+ - metrics-redis-key-pattern.rb
180
+ - check-cassandra-nodes.rb
181
+ - metrics-aws-elb.rb
166
182
  - check-logstash-pipeline.rb
167
- - check-nomad-jobs.rb
183
+ - metrics-aws-asg.rb
168
184
  extensions: []
169
185
  extra_rdoc_files: []
170
186
  files:
171
187
  - bin/check-apt-expired-keys.rb
188
+ - bin/check-cassandra-nodes.rb
172
189
  - bin/check-consul-services.rb
173
190
  - bin/check-logstash-pipeline.rb
174
191
  - bin/check-nomad-jobs.rb
@@ -177,6 +194,7 @@ files:
177
194
  - bin/metrics-aws-asg.rb
178
195
  - bin/metrics-aws-elb.rb
179
196
  - bin/metrics-aws-rds.rb
197
+ - bin/metrics-cassandra-basic.rb
180
198
  - bin/metrics-es-indices.rb
181
199
  - bin/metrics-redis-key-pattern.rb
182
200
  - bin/metrics-swarm-cluster.rb