sensu-plugins-edgelab 1.7.2 → 1.8.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/metrics-es-indices.rb +113 -0
  3. metadata +10 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 726b908b3f39574da4da9f51dcc0621d54b02e75
4
- data.tar.gz: 9d26669a1bbc481833f284bcdaebbf2d51484bff
3
+ metadata.gz: c8a85afe1c5721e4a4babcc789e8077eb93a64d8
4
+ data.tar.gz: beddf95751a6e2e5d4467247cf2dfadde5a96b08
5
5
  SHA512:
6
- metadata.gz: 8a1e68d2eee4f02a002709af3ebbca04718beabb8b623e013c668e9bf714bb01e9342c7bce75f79ffe5efafee2d1e5adf7bb0702eee512f7008f32f21cde04f4
7
- data.tar.gz: 2b4b5af8c17d4730f8f5c1e0910f395a95eb467e44002caae69de9a7cc940d46ef05addf61c36ba318cd68b6f2b6662e173247b7cd82a4c899cbe665e32ece26
6
+ metadata.gz: e749f45691ac4a55baef21aa9863466de7394f02213df48be764e846383f81bd6de4a4a7d14256b5a7771536eac4486a4f801555ffe97d33fbfe8e46a1a5334e
7
+ data.tar.gz: db8b8aa3390248f212ba5f1f86138cf96804c09d431fedd5cadfcfc29df101cdc156c759336376efb592ef47f6e214c9265932830bb4a78d0211bb024067ca0a
@@ -0,0 +1,113 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # metrics-es-indices
4
+ #
5
+ # DESCRIPTION:
6
+ # This plugin uses the ES API to collect index-related metrics, producing a
7
+ # JSON document which is outputted to STDOUT. An exit status of 0 indicates
8
+ # the plugin has successfully collected and produced metrics.
9
+ #
10
+ # OUTPUT:
11
+ # metric data
12
+ #
13
+ # PLATFORMS:
14
+ # Linux
15
+ #
16
+ # DEPENDENCIES:
17
+ # gem: sensu-plugin
18
+ # gem: rest-client
19
+ #
20
+ # USAGE:
21
+ # #YELLOW
22
+ #
23
+ # NOTES:
24
+ #
25
+ # LICENSE:
26
+ # Copyright 2017 EdgeLaboratories.
27
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
28
+ # for details.
29
+ #
30
+
31
+ require 'sensu-plugin/metric/cli'
32
+ require 'rest-client'
33
+ require 'json'
34
+ require 'base64'
35
+
36
+ #
37
+ # ES Indices Metrics
38
+ #
39
+ class ESIndicesMetrics < Sensu::Plugin::Metric::CLI::Graphite
40
+ option :scheme,
41
+ description: 'Metric naming scheme, text to prepend to metric',
42
+ short: '-s SCHEME',
43
+ long: '--scheme SCHEME',
44
+ default: "#{Socket.gethostname}.elasticsearch.index"
45
+
46
+ option :host,
47
+ description: 'Elasticsearch host',
48
+ short: '-h HOST',
49
+ long: '--host HOST',
50
+ default: 'localhost'
51
+
52
+ option :port,
53
+ description: 'Elasticsearch port',
54
+ short: '-p PORT',
55
+ long: '--port PORT',
56
+ proc: proc(&:to_i),
57
+ default: 9200
58
+
59
+ option :timeout,
60
+ description: 'Sets the connection timeout for REST client',
61
+ short: '-t SECS',
62
+ long: '--timeout SECS',
63
+ proc: proc(&:to_i),
64
+ default: 30
65
+
66
+ option :user,
67
+ description: 'Elasticsearch User',
68
+ short: '-u USER',
69
+ long: '--user USER'
70
+
71
+ option :password,
72
+ description: 'Elasticsearch Password',
73
+ short: '-P PASS',
74
+ long: '--password PASS'
75
+
76
+ option :https,
77
+ description: 'Enables HTTPS',
78
+ short: '-e',
79
+ long: '--https'
80
+
81
+ def get_es_resource(resource)
82
+ headers = {}
83
+ if config[:user] && config[:password]
84
+ auth = 'Basic ' + Base64.strict_encode64("#{config[:user]}:#{config[:password]}").chomp
85
+ headers = { 'Authorization' => auth }
86
+ end
87
+
88
+ protocol = if config[:https]
89
+ 'https'
90
+ else
91
+ 'http'
92
+ end
93
+
94
+ r = RestClient::Resource.new("#{protocol}://#{config[:host]}:#{config[:port]}#{resource}", timeout: config[:timeout], headers: headers)
95
+ JSON.parse(r.get)
96
+ rescue Errno::ECONNREFUSED
97
+ warning 'Connection refused'
98
+ rescue RestClient::RequestTimeout
99
+ warning 'Connection timed out'
100
+ end
101
+
102
+ def run
103
+ indices_stats = get_es_resource('/_stats/docs,store')
104
+
105
+ indices_stats['indices'].each do |name, index|
106
+ name = name.tr('.', '_')
107
+ output(config[:scheme] + '.' + name + '.documents.total', index['total']['docs']['count'])
108
+ output(config[:scheme] + '.' + name + '.documents.deleted', index['total']['docs']['deleted'])
109
+ output(config[:scheme] + '.' + name + '.disk_size.bytes', index['total']['store']['size_in_bytes'])
110
+ end
111
+ ok
112
+ end
113
+ 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.7.2
4
+ version: 1.8.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-04-20 00:00:00.000000000 Z
11
+ date: 2017-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -153,17 +153,18 @@ dependencies:
153
153
  description: Sensu plugins developed by Edgelab
154
154
  email:
155
155
  executables:
156
+ - metrics-es-indices.rb
156
157
  - metrics-aws-elb.rb
158
+ - metrics-swarm-cluster.rb
159
+ - metrics-aws-asg.rb
160
+ - check-nomad-leader.rb
157
161
  - metrics-mysql-processes.rb
162
+ - check-swarm-cluster.rb
163
+ - check-apt-expired-keys.rb
158
164
  - check-nomad-jobs.rb
159
- - metrics-aws-rds.rb
160
165
  - metrics-redis-key-pattern.rb
161
- - check-nomad-leader.rb
162
- - metrics-aws-asg.rb
163
- - check-swarm-cluster.rb
164
166
  - check-consul-services.rb
165
- - check-apt-expired-keys.rb
166
- - metrics-swarm-cluster.rb
167
+ - metrics-aws-rds.rb
167
168
  extensions: []
168
169
  extra_rdoc_files: []
169
170
  files:
@@ -175,6 +176,7 @@ files:
175
176
  - bin/metrics-aws-asg.rb
176
177
  - bin/metrics-aws-elb.rb
177
178
  - bin/metrics-aws-rds.rb
179
+ - bin/metrics-es-indices.rb
178
180
  - bin/metrics-mysql-processes.rb
179
181
  - bin/metrics-redis-key-pattern.rb
180
182
  - bin/metrics-swarm-cluster.rb