sensu-plugins-elasticsearch 0.4.3 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +13 -3
- data/README.md +3 -1
- data/bin/check-es-circuit-breakers.rb +13 -1
- data/bin/check-es-cluster-status.rb +13 -1
- data/bin/check-es-file-descriptors.rb +13 -1
- data/bin/check-es-heap.rb +13 -1
- data/bin/check-es-indexes.rb +89 -0
- data/bin/check-es-node-status.rb +13 -1
- data/bin/check-es-query-count.rb +16 -5
- data/bin/check-es-query-exists.rb +16 -5
- data/bin/check-es-shard-allocation-status.rb +96 -0
- data/bin/metrics-es-cluster.rb +13 -1
- data/bin/metrics-es-node-graphite.rb +13 -1
- data/bin/metrics-es-node.rb +13 -1
- data/lib/sensu-plugins-elasticsearch/elasticsearch-query.rb +19 -23
- data/lib/sensu-plugins-elasticsearch/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjkwYTFiOWMzYjAzMzY0OTNiZjE5ZDZkNWY3NTliNzJiMGU2NWQ4ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OWI1ZTYzMjU5NTM1MzljZDA5NTlkOTViYThiNzBlZDY0ODQ2NTA1Yg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGNhNjRjZWEzZjQ2OTBlYjI5OTJjY2Y5YmFmOTc5ZTE2YjFhODNjYjc2OWMy
|
10
|
+
YmQ0OWMyZWRlMWJjYTMwODU2MzQxNjc3ZjFmYTI2ZTliODI1ODQxMmFmOGQz
|
11
|
+
ZDNkNjFkNTU5OTFhYjdiNWEzYjQ2NzAyMDc2MTIwNzAxNmMwODQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MzYyODViMzE4OTExZGU1Y2RjMWJkY2UzNTVjMGZiY2Q1Y2QzNGJjZGY2NGQ0
|
14
|
+
YTRkOWEzNTA0MThkYzE5ZDI1NjNhOWM1YjAyMGQwNzk5MjQ3ZDAzMzY0N2I1
|
15
|
+
YTUzNDJhYTRmMTJlMDFiNzIzMjVmMGNkZTRjOGNlZjZkNDRiYmY=
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,15 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [0.5.3] - 2016-04-02
|
9
|
+
### Added
|
10
|
+
- check-es-indexes (check for dup indexes) (Yieldbot)
|
11
|
+
- check-es-shard-allocation (check ElasticSearch shard allocation persistent and transient settings) (Yieldbot)
|
12
|
+
- Adding offset flag to allow specifying of a end time offset
|
13
|
+
- Adding custom timestamp field feature to check-es-query-count and check-es-query-exists
|
14
|
+
- Added support for https requests (OrbotixInc)
|
15
|
+
|
16
|
+
|
8
17
|
## [0.4.3] - 2016-02-22
|
9
18
|
### Fixed
|
10
19
|
- metrics-es-heap.rb: Assignment of node from the stats variable happened before stats was assigned. Moved node assignment to be after stats assignment.
|
@@ -13,7 +22,7 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
13
22
|
### Added
|
14
23
|
- metrics-es-cluster.rb: Added i/o cluster stats
|
15
24
|
|
16
|
-
## [0.4.1] - 2016-01-26
|
25
|
+
## [0.4.1] - 2016-01-26
|
17
26
|
### Fixed
|
18
27
|
- metrics-es-cluster.rb: Allow metrics to be gathered even if the cluster has zero documents. Also updated cache name for Elasticsearch 2.0+
|
19
28
|
- metrics-es-node-graphite.rb: Update node stats for Elasticsearch 2.0+
|
@@ -76,8 +85,9 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
76
85
|
### Added
|
77
86
|
- initial release
|
78
87
|
|
79
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.
|
80
|
-
[0.
|
88
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.5.3...HEAD
|
89
|
+
[0.5.3]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.4.2...0.4.3
|
90
|
+
[0.4.3]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.4.2...0.4.3
|
81
91
|
[0.4.2]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.4.1...0.4.2
|
82
92
|
[0.4.1]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.4.0...0.4.1
|
83
93
|
[0.4.0]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.3.2...0.4.0
|
data/README.md
CHANGED
@@ -9,13 +9,15 @@
|
|
9
9
|
## Functionality
|
10
10
|
|
11
11
|
## Files
|
12
|
+
* /bin/check-es-circuit-breakers.rb
|
12
13
|
* /bin/check-es-cluster-status.rb
|
13
14
|
* /bin/check-es-file-descriptors.rb
|
14
15
|
* /bin/check-es-heap.rb
|
16
|
+
* /bin/check-es-indexes.rb
|
15
17
|
* /bin/check-es-node-status.rb
|
16
18
|
* /bin/check-es-query-count.rb
|
17
19
|
* /bin/check-es-query-exists.rb
|
18
|
-
* /bin/check-es-
|
20
|
+
* /bin/check-es-shard-allocation
|
19
21
|
* /bin/metrics-es-cluster.rb
|
20
22
|
* /bin/metrics-es-node.rb
|
21
23
|
* /bin/metrics-es-node-graphite.rb
|
@@ -64,13 +64,25 @@ class ESCircuitBreaker < Sensu::Plugin::Check::CLI
|
|
64
64
|
short: '-P PASS',
|
65
65
|
long: '--password PASS'
|
66
66
|
|
67
|
+
option :https,
|
68
|
+
description: 'Enables HTTPS',
|
69
|
+
short: '-e',
|
70
|
+
long: '--https'
|
71
|
+
|
67
72
|
def get_es_resource(resource)
|
68
73
|
headers = {}
|
69
74
|
if config[:user] && config[:password]
|
70
75
|
auth = 'Basic ' + Base64.encode64("#{config[:user]}:#{config[:password]}").chomp
|
71
76
|
headers = { 'Authorization' => auth }
|
72
77
|
end
|
73
|
-
|
78
|
+
|
79
|
+
protocol = if config[:https]
|
80
|
+
'https'
|
81
|
+
else
|
82
|
+
'http'
|
83
|
+
end
|
84
|
+
|
85
|
+
r = RestClient::Resource.new("#{protocol}://#{config[:host]}:#{config[:port]}#{resource}", timeout: config[:timeout], headers: headers)
|
74
86
|
JSON.parse(r.get)
|
75
87
|
rescue Errno::ECONNREFUSED
|
76
88
|
critical 'Connection refused'
|
@@ -78,13 +78,25 @@ class ESClusterStatus < Sensu::Plugin::Check::CLI
|
|
78
78
|
short: '-P PASS',
|
79
79
|
long: '--password PASS'
|
80
80
|
|
81
|
+
option :https,
|
82
|
+
description: 'Enables HTTPS',
|
83
|
+
short: '-e',
|
84
|
+
long: '--https'
|
85
|
+
|
81
86
|
def get_es_resource(resource)
|
82
87
|
headers = {}
|
83
88
|
if config[:user] && config[:password]
|
84
89
|
auth = 'Basic ' + Base64.encode64("#{config[:user]}:#{config[:password]}").chomp
|
85
90
|
headers = { 'Authorization' => auth }
|
86
91
|
end
|
87
|
-
|
92
|
+
|
93
|
+
protocol = if config[:https]
|
94
|
+
'https'
|
95
|
+
else
|
96
|
+
'http'
|
97
|
+
end
|
98
|
+
|
99
|
+
r = RestClient::Resource.new("#{protocol}://#{config[:host]}:#{config[:port]}#{resource}", timeout: config[:timeout], headers: headers)
|
88
100
|
JSON.parse(r.get)
|
89
101
|
rescue Errno::ECONNREFUSED
|
90
102
|
critical 'Connection refused'
|
@@ -77,13 +77,25 @@ class ESFileDescriptors < Sensu::Plugin::Check::CLI
|
|
77
77
|
short: '-P PASS',
|
78
78
|
long: '--password PASS'
|
79
79
|
|
80
|
+
option :https,
|
81
|
+
description: 'Enables HTTPS',
|
82
|
+
short: '-e',
|
83
|
+
long: '--https'
|
84
|
+
|
80
85
|
def get_es_resource(resource)
|
81
86
|
headers = {}
|
82
87
|
if config[:user] && config[:password]
|
83
88
|
auth = 'Basic ' + Base64.encode64("#{config[:user]}:#{config[:password]}").chomp
|
84
89
|
headers = { 'Authorization' => auth }
|
85
90
|
end
|
86
|
-
|
91
|
+
|
92
|
+
protocol = if config[:https]
|
93
|
+
'https'
|
94
|
+
else
|
95
|
+
'http'
|
96
|
+
end
|
97
|
+
|
98
|
+
r = RestClient::Resource.new("#{protocol}://#{config[:host]}:#{config[:port]}#{resource}", timeout: config[:timeout], headers: headers)
|
87
99
|
JSON.parse(r.get)
|
88
100
|
rescue Errno::ECONNREFUSED
|
89
101
|
warning 'Connection refused'
|
data/bin/check-es-heap.rb
CHANGED
@@ -85,6 +85,11 @@ class ESHeap < Sensu::Plugin::Check::CLI
|
|
85
85
|
short: '-W PASS',
|
86
86
|
long: '--password PASS'
|
87
87
|
|
88
|
+
option :https,
|
89
|
+
description: 'Enables HTTPS',
|
90
|
+
short: '-e',
|
91
|
+
long: '--https'
|
92
|
+
|
88
93
|
def acquire_es_version
|
89
94
|
info = acquire_es_resource('/')
|
90
95
|
info['version']['number']
|
@@ -96,7 +101,14 @@ class ESHeap < Sensu::Plugin::Check::CLI
|
|
96
101
|
auth = 'Basic ' + Base64.encode64("#{config[:user]}:#{config[:password]}").chomp
|
97
102
|
headers = { 'Authorization' => auth }
|
98
103
|
end
|
99
|
-
|
104
|
+
|
105
|
+
protocol = if config[:https]
|
106
|
+
'https'
|
107
|
+
else
|
108
|
+
'http'
|
109
|
+
end
|
110
|
+
|
111
|
+
r = RestClient::Resource.new("#{protocol}://#{config[:host]}:#{config[:port]}#{resource}", timeout: config[:timeout], headers: headers)
|
100
112
|
JSON.parse(r.get)
|
101
113
|
rescue Errno::ECONNREFUSED
|
102
114
|
warning 'Connection refused'
|
@@ -0,0 +1,89 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Check Elastic Search Indexes
|
4
|
+
# ===
|
5
|
+
#
|
6
|
+
# DESCRIPTION:
|
7
|
+
# This plugin will check a a node for dupe indexes
|
8
|
+
#
|
9
|
+
# OUTPUT:
|
10
|
+
# plain-text
|
11
|
+
#
|
12
|
+
# PLATFORMS:
|
13
|
+
# Linux
|
14
|
+
#
|
15
|
+
# DEPENDENCIES:
|
16
|
+
# gem: sensu-plugin
|
17
|
+
#
|
18
|
+
# needs usage
|
19
|
+
# USAGE:
|
20
|
+
#
|
21
|
+
# NOTES:
|
22
|
+
#
|
23
|
+
# LICENSE:
|
24
|
+
# Copyright 2014 Yieldbot, Inc <devops@yieldbot.com>
|
25
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
26
|
+
# for details.
|
27
|
+
#
|
28
|
+
|
29
|
+
require 'sensu-plugin/check/cli'
|
30
|
+
|
31
|
+
#
|
32
|
+
# == Check Elastic Search Cluster Index
|
33
|
+
#
|
34
|
+
class CheckESClusterIndex < Sensu::Plugin::Check::CLI
|
35
|
+
option :cluster,
|
36
|
+
description: 'Array of clusters to check',
|
37
|
+
short: '-C CLUSTER[,CLUSTER]',
|
38
|
+
long: '--cluster CLUSTER[,CLUSTER]',
|
39
|
+
proc: proc { |a| a.split(',') }
|
40
|
+
|
41
|
+
option :ignore,
|
42
|
+
description: 'Comma separated list of indexes to ignore',
|
43
|
+
short: '-i INDEX[,INDEX]',
|
44
|
+
long: '--ignore INDEX[,INDEX]',
|
45
|
+
proc: proc { |a| a.split(',') }
|
46
|
+
|
47
|
+
option :debug,
|
48
|
+
description: 'Debug',
|
49
|
+
short: '-d',
|
50
|
+
long: '--debug'
|
51
|
+
|
52
|
+
def run
|
53
|
+
# If only one cluster is given, no need to check the indexes
|
54
|
+
ok 'All indexes are unique' if config[:cluster].length == 1
|
55
|
+
|
56
|
+
port = ':9200'
|
57
|
+
cmd = '/_cat/indices?v | tail -n +2'
|
58
|
+
|
59
|
+
valid_index = {}
|
60
|
+
dupe_index = {}
|
61
|
+
config[:cluster].each do |u|
|
62
|
+
index_arr = `curl -s #{ u }#{ port }#{ cmd }`.split("\n")
|
63
|
+
index_arr.each do |t|
|
64
|
+
t = t.split[1]
|
65
|
+
|
66
|
+
# If the index is in the ignore list, go to the next one
|
67
|
+
next if config[:ignore].include? t
|
68
|
+
|
69
|
+
if valid_index.key?(t)
|
70
|
+
dupe_index[t] = [] unless dupe_index[t].is_a?(Array)
|
71
|
+
dupe_index[t] << u
|
72
|
+
dupe_index[t] << valid_index[t] unless dupe_index[t]
|
73
|
+
.include?(valid_index[t])
|
74
|
+
else
|
75
|
+
valid_index[t] = [] unless valid_index[t].is_a?(Array)
|
76
|
+
valid_index[t] << u
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
if dupe_index.count > 0
|
82
|
+
dupe_index.each do |k, v|
|
83
|
+
critical "#{k} is on #{v}"
|
84
|
+
end
|
85
|
+
else
|
86
|
+
ok 'All indexes are unique'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/bin/check-es-node-status.rb
CHANGED
@@ -63,13 +63,25 @@ class ESNodeStatus < Sensu::Plugin::Check::CLI
|
|
63
63
|
short: '-P PASS',
|
64
64
|
long: '--password PASS'
|
65
65
|
|
66
|
+
option :https,
|
67
|
+
description: 'Enables HTTPS',
|
68
|
+
short: '-e',
|
69
|
+
long: '--https'
|
70
|
+
|
66
71
|
def get_es_resource(resource)
|
67
72
|
headers = {}
|
68
73
|
if config[:user] && config[:password]
|
69
74
|
auth = 'Basic ' + Base64.encode64("#{config[:user]}:#{config[:password]}").chomp
|
70
75
|
headers = { 'Authorization' => auth }
|
71
76
|
end
|
72
|
-
|
77
|
+
|
78
|
+
protocol = if config[:https]
|
79
|
+
'https'
|
80
|
+
else
|
81
|
+
'http'
|
82
|
+
end
|
83
|
+
|
84
|
+
r = RestClient::Resource.new("#{protocol}://#{config[:host]}:#{config[:port]}#{resource}", timeout: config[:timeout], headers: headers)
|
73
85
|
r.get
|
74
86
|
rescue Errno::ECONNREFUSED
|
75
87
|
critical 'Connection refused'
|
data/bin/check-es-query-count.rb
CHANGED
@@ -54,32 +54,43 @@ class ESQueryCount < Sensu::Plugin::Check::CLI
|
|
54
54
|
description: 'Elasticsearch types to limit searches to, comma separated list.',
|
55
55
|
long: '--types TYPES'
|
56
56
|
|
57
|
+
option :timestamp_field,
|
58
|
+
description: 'Field to use instead of @timestamp for query.',
|
59
|
+
long: '--timestamp-field FIELD_NAME',
|
60
|
+
default: '@timestamp'
|
61
|
+
|
62
|
+
option :offset,
|
63
|
+
description: 'Seconds before offset to end @timestamp against query.',
|
64
|
+
long: '--offset OFFSET',
|
65
|
+
proc: proc(&:to_i),
|
66
|
+
default: 0
|
67
|
+
|
57
68
|
option :minutes_previous,
|
58
|
-
description: 'Minutes before
|
69
|
+
description: 'Minutes before offset to check @timestamp against query.',
|
59
70
|
long: '--minutes-previous MINUTES_PREVIOUS',
|
60
71
|
proc: proc(&:to_i),
|
61
72
|
default: 0
|
62
73
|
|
63
74
|
option :hours_previous,
|
64
|
-
description: 'Hours before
|
75
|
+
description: 'Hours before offset to check @timestamp against query.',
|
65
76
|
long: '--hours-previous HOURS_PREVIOUS',
|
66
77
|
proc: proc(&:to_i),
|
67
78
|
default: 0
|
68
79
|
|
69
80
|
option :days_previous,
|
70
|
-
description: 'Days before
|
81
|
+
description: 'Days before offset to check @timestamp against query.',
|
71
82
|
long: '--days-previous DAYS_PREVIOUS',
|
72
83
|
proc: proc(&:to_i),
|
73
84
|
default: 0
|
74
85
|
|
75
86
|
option :weeks_previous,
|
76
|
-
description: 'Weeks before
|
87
|
+
description: 'Weeks before offset to check @timestamp against query.',
|
77
88
|
long: '--weeks-previous WEEKS_PREVIOUS',
|
78
89
|
proc: proc(&:to_i),
|
79
90
|
default: 0
|
80
91
|
|
81
92
|
option :months_previous,
|
82
|
-
description: 'Months before
|
93
|
+
description: 'Months before offset to check @timestamp against query.',
|
83
94
|
long: '--months-previous MONTHS_PREVIOUS',
|
84
95
|
proc: proc(&:to_i),
|
85
96
|
default: 0
|
@@ -55,32 +55,43 @@ class ESQueryExists < Sensu::Plugin::Check::CLI
|
|
55
55
|
description: 'Elasticsearch types to limit searches to, comma separated list.',
|
56
56
|
long: '--types TYPES'
|
57
57
|
|
58
|
+
option :timestamp_field,
|
59
|
+
description: 'Field to use instead of @timestamp for query.',
|
60
|
+
long: '--timestamp_field FIELD_NAME',
|
61
|
+
default: '@timestamp'
|
62
|
+
|
63
|
+
option :offset,
|
64
|
+
description: 'Seconds before offset to end @timestamp against query.',
|
65
|
+
long: '--offset OFFSET',
|
66
|
+
proc: proc(&:to_i),
|
67
|
+
default: 0
|
68
|
+
|
58
69
|
option :minutes_previous,
|
59
|
-
description: 'Minutes before
|
70
|
+
description: 'Minutes before offset to check @timestamp against query.',
|
60
71
|
long: '--minutes-previous MINUTES_PREVIOUS',
|
61
72
|
proc: proc(&:to_i),
|
62
73
|
default: 0
|
63
74
|
|
64
75
|
option :hours_previous,
|
65
|
-
description: 'Hours before
|
76
|
+
description: 'Hours before offset to check @timestamp against query.',
|
66
77
|
long: '--hours-previous DAYS_PREVIOUS',
|
67
78
|
proc: proc(&:to_i),
|
68
79
|
default: 0
|
69
80
|
|
70
81
|
option :days_previous,
|
71
|
-
description: 'Days before
|
82
|
+
description: 'Days before offset to check @timestamp against query.',
|
72
83
|
long: '--days-previous DAYS_PREVIOUS',
|
73
84
|
proc: proc(&:to_i),
|
74
85
|
default: 0
|
75
86
|
|
76
87
|
option :weeks_previous,
|
77
|
-
description: 'Weeks before
|
88
|
+
description: 'Weeks before offset to check @timestamp against query.',
|
78
89
|
long: '--weeks-previous WEEKS_PREVIOUS',
|
79
90
|
proc: proc(&:to_i),
|
80
91
|
default: 0
|
81
92
|
|
82
93
|
option :months_previous,
|
83
|
-
description: 'Months before
|
94
|
+
description: 'Months before offset to check @timestamp against query.',
|
84
95
|
long: '--months-previous MONTHS_PREVIOUS',
|
85
96
|
proc: proc(&:to_i),
|
86
97
|
default: 0
|
@@ -0,0 +1,96 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Checks ElasticSearch shard allocation setting status
|
4
|
+
# ===
|
5
|
+
#
|
6
|
+
# DESCRIPTION:
|
7
|
+
# Checks the ElasticSearch shard allocation persistent and transient settings
|
8
|
+
# and will return status based on a difference in those settings.
|
9
|
+
#
|
10
|
+
# OUTPUT:
|
11
|
+
# plain-text
|
12
|
+
#
|
13
|
+
# PLATFORMS:
|
14
|
+
# Linux
|
15
|
+
#
|
16
|
+
# DEPENDENCIES:
|
17
|
+
# gem: sensu-plugin
|
18
|
+
# gem: rest-client
|
19
|
+
#
|
20
|
+
# USAGE:
|
21
|
+
#
|
22
|
+
# NOTES:
|
23
|
+
#
|
24
|
+
# LICENSE:
|
25
|
+
# Copyright 2014 Yieldbot, Inc <devops@yieldbot.com>
|
26
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
27
|
+
# for details.
|
28
|
+
#
|
29
|
+
|
30
|
+
require 'sensu-plugin/check/cli'
|
31
|
+
require 'rest-client'
|
32
|
+
require 'json'
|
33
|
+
|
34
|
+
#
|
35
|
+
# == Elastic Search Shard Allocation Status
|
36
|
+
#
|
37
|
+
class ESShardAllocationStatus < Sensu::Plugin::Check::CLI
|
38
|
+
option :scheme,
|
39
|
+
description: 'URI scheme',
|
40
|
+
long: '--scheme SCHEME',
|
41
|
+
default: 'http'
|
42
|
+
|
43
|
+
option :server,
|
44
|
+
description: 'Elasticsearch server',
|
45
|
+
short: '-s SERVER',
|
46
|
+
long: '--server SERVER',
|
47
|
+
default: 'localhost'
|
48
|
+
|
49
|
+
option :port,
|
50
|
+
description: 'Port',
|
51
|
+
short: '-p PORT',
|
52
|
+
long: '--port PORT',
|
53
|
+
default: '9200'
|
54
|
+
|
55
|
+
def get_es_resource(resource)
|
56
|
+
r = RestClient::Resource.new("#{config[:scheme]}://#{config[:server]}:#{config[:port]}/#{resource}", timeout: 45)
|
57
|
+
JSON.parse(r.get)
|
58
|
+
rescue Errno::ECONNREFUSED
|
59
|
+
warning 'Connection refused'
|
60
|
+
rescue RestClient::RequestTimeout
|
61
|
+
warning 'Connection timed out'
|
62
|
+
end
|
63
|
+
|
64
|
+
def master?
|
65
|
+
state = get_es_resource('/_cluster/state?filter_routing_table=true&filter_metadata=true&filter_indices=true&filter_blocks=true&filter_nodes=true')
|
66
|
+
local = get_es_resource('/_nodes/_local')
|
67
|
+
local['nodes'].keys.first == state['master_node']
|
68
|
+
end
|
69
|
+
|
70
|
+
def get_status(type)
|
71
|
+
settings = get_es_resource('/_cluster/settings')
|
72
|
+
# Get the status for the given type, or default to 'all'
|
73
|
+
# which is the ES default
|
74
|
+
begin
|
75
|
+
settings[type]['cluster']['routing']['allocation']['enable'].downcase
|
76
|
+
rescue
|
77
|
+
'all'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def run
|
82
|
+
if master?
|
83
|
+
transient = get_status('transient')
|
84
|
+
persistent = get_status('persistent')
|
85
|
+
|
86
|
+
if transient == persistent
|
87
|
+
ok "Persistent and transient allocation match: #{persistent}"
|
88
|
+
else
|
89
|
+
critical "Persistent(#{persistent}) and transient(#{transient}) \
|
90
|
+
shard allocation do not match."
|
91
|
+
end
|
92
|
+
else
|
93
|
+
ok 'Not the master'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/bin/metrics-es-cluster.rb
CHANGED
@@ -85,6 +85,11 @@ class ESClusterMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
85
85
|
short: '-P PASS',
|
86
86
|
long: '--password PASS'
|
87
87
|
|
88
|
+
option :https,
|
89
|
+
description: 'Enables HTTPS',
|
90
|
+
short: '-e',
|
91
|
+
long: '--https'
|
92
|
+
|
88
93
|
def acquire_es_version
|
89
94
|
info = get_es_resource('/')
|
90
95
|
info['version']['number']
|
@@ -96,7 +101,14 @@ class ESClusterMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
96
101
|
auth = 'Basic ' + Base64.encode64("#{config[:user]}:#{config[:password]}").chomp
|
97
102
|
headers = { 'Authorization' => auth }
|
98
103
|
end
|
99
|
-
|
104
|
+
|
105
|
+
protocol = if config[:https]
|
106
|
+
'https'
|
107
|
+
else
|
108
|
+
'http'
|
109
|
+
end
|
110
|
+
|
111
|
+
r = RestClient::Resource.new("#{protocol}://#{config[:host]}:#{config[:port]}#{resource}", timeout: config[:timeout], headers: headers)
|
100
112
|
JSON.parse(r.get)
|
101
113
|
rescue Errno::ECONNREFUSED
|
102
114
|
warning 'Connection refused'
|
@@ -110,13 +110,25 @@ class ESNodeGraphiteMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
110
110
|
short: '-P PASS',
|
111
111
|
long: '--password PASS'
|
112
112
|
|
113
|
+
option :https,
|
114
|
+
description: 'Enables HTTPS',
|
115
|
+
short: '-e',
|
116
|
+
long: '--https'
|
117
|
+
|
113
118
|
def get_es_resource(resource)
|
114
119
|
headers = {}
|
115
120
|
if config[:user] && config[:password]
|
116
121
|
auth = 'Basic ' + Base64.encode64("#{config[:user]}:#{config[:password]}").chomp
|
117
122
|
headers = { 'Authorization' => auth }
|
118
123
|
end
|
119
|
-
|
124
|
+
|
125
|
+
protocol = if config[:https]
|
126
|
+
'https'
|
127
|
+
else
|
128
|
+
'http'
|
129
|
+
end
|
130
|
+
|
131
|
+
r = RestClient::Resource.new("#{protocol}://#{config[:server]}:#{config[:port]}#{resource}?pretty", timeout: config[:timeout], headers: headers)
|
120
132
|
JSON.parse(r.get)
|
121
133
|
rescue Errno::ECONNREFUSED
|
122
134
|
warning 'Connection refused'
|
data/bin/metrics-es-node.rb
CHANGED
@@ -66,6 +66,11 @@ class ESMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
66
66
|
short: '-P PASS',
|
67
67
|
long: '--password PASS'
|
68
68
|
|
69
|
+
option :https,
|
70
|
+
description: 'Enables HTTPS',
|
71
|
+
short: '-e',
|
72
|
+
long: '--https'
|
73
|
+
|
69
74
|
def acquire_es_version
|
70
75
|
info = get_es_resource('/')
|
71
76
|
info['version']['number']
|
@@ -77,7 +82,14 @@ class ESMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
77
82
|
auth = 'Basic ' + Base64.encode64("#{config[:user]}:#{config[:password]}").chomp
|
78
83
|
headers = { 'Authorization' => auth }
|
79
84
|
end
|
80
|
-
|
85
|
+
|
86
|
+
protocol = if config[:https]
|
87
|
+
'https'
|
88
|
+
else
|
89
|
+
'http'
|
90
|
+
end
|
91
|
+
|
92
|
+
r = RestClient::Resource.new("#{protocol}://#{config[:host]}:#{config[:port]}#{resource}", timeout: config[:timeout], headers: headers)
|
81
93
|
JSON.parse(r.get)
|
82
94
|
rescue Errno::ECONNREFUSED
|
83
95
|
warning 'Connection refused'
|
@@ -21,12 +21,13 @@ module ElasticsearchQuery
|
|
21
21
|
super()
|
22
22
|
end
|
23
23
|
|
24
|
-
def indices
|
24
|
+
def indices(end_time)
|
25
25
|
if !config[:index].nil?
|
26
26
|
return config[:index]
|
27
27
|
elsif !config[:date_index].nil?
|
28
28
|
indices = []
|
29
|
-
|
29
|
+
|
30
|
+
curr = end_time.to_i
|
30
31
|
start = curr
|
31
32
|
|
32
33
|
if config[:minutes_previous] != 0
|
@@ -60,15 +61,17 @@ module ElasticsearchQuery
|
|
60
61
|
end
|
61
62
|
|
62
63
|
def build_request_options
|
64
|
+
end_time = (Time.now.utc - config[:offset])
|
63
65
|
options = {
|
64
|
-
index: indices,
|
66
|
+
index: indices(end_time),
|
65
67
|
ignore_unavailable: true
|
66
68
|
}
|
69
|
+
|
67
70
|
if !config[:body].nil?
|
68
71
|
options[:body] = config[:body]
|
69
72
|
else
|
70
|
-
|
71
|
-
unless
|
73
|
+
es_date_start = es_date_math_string end_time
|
74
|
+
unless es_date_start.nil?
|
72
75
|
options[:body] = {
|
73
76
|
'query' => {
|
74
77
|
'filtered' => {
|
@@ -80,7 +83,10 @@ module ElasticsearchQuery
|
|
80
83
|
},
|
81
84
|
'filter' => {
|
82
85
|
'range' => {
|
83
|
-
|
86
|
+
config[:timestamp_field] => {
|
87
|
+
'gt' => es_date_start,
|
88
|
+
'lt' => end_time.strftime('%Y-%m-%dT%H:%M:%S')
|
89
|
+
}
|
84
90
|
}
|
85
91
|
}
|
86
92
|
}
|
@@ -94,7 +100,7 @@ module ElasticsearchQuery
|
|
94
100
|
options
|
95
101
|
end
|
96
102
|
|
97
|
-
def es_date_math_string
|
103
|
+
def es_date_math_string(end_time)
|
98
104
|
if config[:minutes_previous] == 0 && \
|
99
105
|
config[:hours_previous] == 0 && \
|
100
106
|
config[:days_previous] == 0 && \
|
@@ -102,22 +108,12 @@ module ElasticsearchQuery
|
|
102
108
|
config[:months_previous] == 0
|
103
109
|
return nil
|
104
110
|
else
|
105
|
-
es_math = "#{
|
106
|
-
if config[:minutes_previous] != 0
|
107
|
-
|
108
|
-
|
109
|
-
if config[:
|
110
|
-
|
111
|
-
end
|
112
|
-
if config[:days_previous] != 0
|
113
|
-
es_math += "-#{config[:days_previous]}d"
|
114
|
-
end
|
115
|
-
if config[:weeks_previous] != 0
|
116
|
-
es_math += "-#{config[:weeks_previous]}w"
|
117
|
-
end
|
118
|
-
if config[:months_previous] != 0
|
119
|
-
es_math += "-#{config[:months_previous]}M"
|
120
|
-
end
|
111
|
+
es_math = "#{end_time.strftime '%Y-%m-%dT%H:%M:%S'}||"
|
112
|
+
es_math += "-#{config[:minutes_previous]}m" if config[:minutes_previous] != 0
|
113
|
+
es_math += "-#{config[:hours_previous]}h" if config[:hours_previous] != 0
|
114
|
+
es_math += "-#{config[:days_previous]}d" if config[:days_previous] != 0
|
115
|
+
es_math += "-#{config[:weeks_previous]}w" if config[:weeks_previous] != 0
|
116
|
+
es_math += "-#{config[:months_previous]}M" if config[:months_previous] != 0
|
121
117
|
return es_math
|
122
118
|
end
|
123
119
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.3
|
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: 2016-02
|
11
|
+
date: 2016-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -187,9 +187,11 @@ executables:
|
|
187
187
|
- check-es-cluster-status.rb
|
188
188
|
- check-es-file-descriptors.rb
|
189
189
|
- check-es-heap.rb
|
190
|
+
- check-es-indexes.rb
|
190
191
|
- check-es-node-status.rb
|
191
192
|
- check-es-query-count.rb
|
192
193
|
- check-es-query-exists.rb
|
194
|
+
- check-es-shard-allocation-status.rb
|
193
195
|
- metrics-es-cluster.rb
|
194
196
|
- metrics-es-node-graphite.rb
|
195
197
|
- metrics-es-node.rb
|
@@ -203,9 +205,11 @@ files:
|
|
203
205
|
- bin/check-es-cluster-status.rb
|
204
206
|
- bin/check-es-file-descriptors.rb
|
205
207
|
- bin/check-es-heap.rb
|
208
|
+
- bin/check-es-indexes.rb
|
206
209
|
- bin/check-es-node-status.rb
|
207
210
|
- bin/check-es-query-count.rb
|
208
211
|
- bin/check-es-query-exists.rb
|
212
|
+
- bin/check-es-shard-allocation-status.rb
|
209
213
|
- bin/metrics-es-cluster.rb
|
210
214
|
- bin/metrics-es-node-graphite.rb
|
211
215
|
- bin/metrics-es-node.rb
|