sensu-plugins-solr 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +19 -2
- data/README.md +2 -1
- data/bin/check-solr-replication-lag.rb +113 -0
- data/lib/sensu-plugins-solr/version.rb +1 -1
- metadata +20 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1d3cf4785148bdb0512d8dc1dd0550761c83a2ff1ca77c55e0209ee123b2adf6
|
4
|
+
data.tar.gz: 95f1d470d18627eb0d4c762b3730a92ded58b229f64d1ffbb9a384ede4bdf506
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15c1206add47b19197ee9bc5625a54390d61827f30083f31d79645baf42b40c3cb9ca6e5ddbbc23b9c3c48a5ae7e46fdbb33c05f82e033f9772146e54908226e
|
7
|
+
data.tar.gz: 14db5d51c7f2670187774155fe86429ea127a4ddf59d96607984cb33ce22c5a9ce3cf4cfef5ba9aacfe560388871ad98afeb4555ae768c176563c8da22067da9
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,25 @@
|
|
1
1
|
# Change Log
|
2
2
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
3
3
|
|
4
|
-
This CHANGELOG follows the format listed
|
4
|
+
This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [1.2.0] - 2023-10-16
|
9
|
+
### Changed
|
10
|
+
- Added backwards compatible support for solr 9.x in `check-solr-replication-lag` by checking both `(follower|slave)` terms in API response (@danieltoader)
|
11
|
+
- Added authentication in `check-solr-replication-lag` (@danieltoader)
|
12
|
+
|
13
|
+
## [1.1.0] - 2018-07-12
|
14
|
+
### Added
|
15
|
+
- Added solr replication lag check (@alexbumbacea)
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
- updated link to changelog guidelines (@majormoses)
|
19
|
+
|
20
|
+
### Fixed
|
21
|
+
- minor typos in PR template (@majormoses)
|
22
|
+
|
8
23
|
## [1.0.0] - 2017-05-10
|
9
24
|
### Added
|
10
25
|
- Ruby 2.3 and 2.4 support (@eheydrick)
|
@@ -30,7 +45,9 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
30
45
|
### Added
|
31
46
|
- initial release
|
32
47
|
|
33
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-solr/compare/1.
|
48
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-solr/compare/1.2.0...HEAD
|
49
|
+
[1.2.0]: https://github.com/sensu-plugins/sensu-plugins-solr/compare/1.1.0...1.2.0
|
50
|
+
[1.1.0]: https://github.com/sensu-plugins/sensu-plugins-solr/compare/1.0.0...1.1.0
|
34
51
|
[1.0.0]: https://github.com/sensu-plugins/sensu-plugins-solr/compare/0.0.3...1.0.0
|
35
52
|
[0.0.3]: https://github.com/sensu-plugins/sensu-plugins-solr/compare/0.0.2...0.0.3
|
36
53
|
[0.0.2]: https://github.com/sensu-plugins/sensu-plugins-solr/compare/0.0.1...0.0.2
|
data/README.md
CHANGED
@@ -12,11 +12,12 @@
|
|
12
12
|
* bin/metrics-solr-graphite.rb
|
13
13
|
* metrics-solr-v1.4graphite.rb
|
14
14
|
* bin/metrics-solr4-graphite.rb
|
15
|
+
* bin/check-solr-replication-lag.rb
|
15
16
|
|
16
17
|
## Usage
|
17
18
|
|
18
19
|
## Installation
|
19
20
|
|
20
|
-
[Installation and Setup](
|
21
|
+
[Installation and Setup](https://docs.sensu.io/sensu-core/latest/installation/installing-plugins/)
|
21
22
|
|
22
23
|
## Notes
|
@@ -0,0 +1,113 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Check how behind replication is.
|
4
|
+
# ===
|
5
|
+
#
|
6
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
7
|
+
# for details.
|
8
|
+
|
9
|
+
require 'sensu-plugin/check/cli'
|
10
|
+
require 'rest-client'
|
11
|
+
require 'json'
|
12
|
+
require 'date'
|
13
|
+
|
14
|
+
class SolrCheckReplication < Sensu::Plugin::Check::CLI
|
15
|
+
option :host,
|
16
|
+
short: '-h HOST',
|
17
|
+
long: '--host HOST',
|
18
|
+
description: 'Solr Host to connect to',
|
19
|
+
required: true
|
20
|
+
|
21
|
+
option :port,
|
22
|
+
short: '-p PORT',
|
23
|
+
long: '--port PORT',
|
24
|
+
description: 'Solr Port to connect to',
|
25
|
+
proc: proc(&:to_i),
|
26
|
+
required: true
|
27
|
+
|
28
|
+
option :protocol,
|
29
|
+
long: '--protocol PROTOCOL',
|
30
|
+
description: 'The connection protocol to use',
|
31
|
+
in: %w(http https), # this controls the acceptable inputs
|
32
|
+
default: 'http'
|
33
|
+
|
34
|
+
option :core,
|
35
|
+
description: 'Solr Core to check',
|
36
|
+
short: '-d CORE',
|
37
|
+
long: '--core CORE',
|
38
|
+
required: true
|
39
|
+
|
40
|
+
option :warning,
|
41
|
+
description: 'Warning if greater than X seconds',
|
42
|
+
short: '-w SECONDS',
|
43
|
+
proc: proc(&:to_i),
|
44
|
+
default: 1200
|
45
|
+
|
46
|
+
option :critical,
|
47
|
+
description: 'Critical if greater than X seconds',
|
48
|
+
short: '-c SECONDS',
|
49
|
+
proc: proc(&:to_i),
|
50
|
+
default: 3600
|
51
|
+
|
52
|
+
option :core_missing_ok,
|
53
|
+
short: '-x',
|
54
|
+
long: '--core-missing-ok',
|
55
|
+
description: 'Allow core to be missing (consider ok)',
|
56
|
+
boolean: true,
|
57
|
+
default: false
|
58
|
+
|
59
|
+
option :username,
|
60
|
+
description: 'Username for HTTP Basic Authentication',
|
61
|
+
short: '-U USERNAME',
|
62
|
+
long: '--username USERNAME',
|
63
|
+
required: false
|
64
|
+
|
65
|
+
option :password,
|
66
|
+
description: 'Password for HTTP Basic Authentication',
|
67
|
+
short: '-P PASSWORD',
|
68
|
+
long: '--password PASSWORD',
|
69
|
+
required: false
|
70
|
+
|
71
|
+
def get_url_json(url, notfoundok, username = nil, password = nil)
|
72
|
+
resource_options = { timeout: 45 }
|
73
|
+
resource_options[:user] = username if username
|
74
|
+
resource_options[:password] = password if password
|
75
|
+
|
76
|
+
r = RestClient::Resource.new(url, resource_options)
|
77
|
+
JSON.parse(r.get)
|
78
|
+
rescue Errno::ECONNREFUSED
|
79
|
+
warning 'Connection refused'
|
80
|
+
rescue RestClient::Unauthorized
|
81
|
+
warning 'Unauthorized: Invalid credentials'
|
82
|
+
rescue RestClient::RequestTimeout
|
83
|
+
warning 'Connection timed out'
|
84
|
+
rescue RestClient::ResourceNotFound
|
85
|
+
if notfoundok
|
86
|
+
ok "404 resource not found - #{url}"
|
87
|
+
else
|
88
|
+
warning "404 resource not found - #{url}"
|
89
|
+
end
|
90
|
+
rescue => e
|
91
|
+
warning "RestClient exception: #{e.class} -> #{e.message}"
|
92
|
+
end
|
93
|
+
|
94
|
+
def run
|
95
|
+
base_core_uri = "#{config[:protocol]}://#{config[:host]}:#{config[:port]}/solr/#{config[:core]}"
|
96
|
+
uri = "#{base_core_uri}/replication?command=details&wt=json"
|
97
|
+
data = get_url_json(uri, config[:core_missing_ok], config[:username], config[:password])
|
98
|
+
details = data['details']
|
99
|
+
if details['isFollower'] == 'true' || details['isSlave'] == 'true'
|
100
|
+
follower_details = details['follower'] || details['slave']
|
101
|
+
lag = (DateTime.parse(follower_details['currentDate']).to_time - DateTime.parse(follower_details['indexReplicatedAt']).to_time).to_i
|
102
|
+
if lag >= config[:critical]
|
103
|
+
critical "Replication lag exceeds #{config[:critical]} seconds (#{lag})"
|
104
|
+
elsif lag >= config[:warning]
|
105
|
+
warning "Replication lag exceeds #{config[:warning]} seconds (#{lag})"
|
106
|
+
else
|
107
|
+
ok "Replication lag is ok (#{lag})"
|
108
|
+
end
|
109
|
+
else
|
110
|
+
ok 'this is not a slave host'
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
metadata
CHANGED
@@ -1,43 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-solr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.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:
|
11
|
+
date: 2023-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1.2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: crack
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - '='
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.4.
|
39
|
+
version: 0.4.3
|
34
40
|
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
44
|
- - '='
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.4.
|
46
|
+
version: 0.4.3
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: rest-client
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,28 +134,28 @@ dependencies:
|
|
128
134
|
requirements:
|
129
135
|
- - "~>"
|
130
136
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
137
|
+
version: '12.3'
|
132
138
|
type: :development
|
133
139
|
prerelease: false
|
134
140
|
version_requirements: !ruby/object:Gem::Requirement
|
135
141
|
requirements:
|
136
142
|
- - "~>"
|
137
143
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
144
|
+
version: '12.3'
|
139
145
|
- !ruby/object:Gem::Dependency
|
140
146
|
name: github-markup
|
141
147
|
requirement: !ruby/object:Gem::Requirement
|
142
148
|
requirements:
|
143
149
|
- - "~>"
|
144
150
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
151
|
+
version: '3.0'
|
146
152
|
type: :development
|
147
153
|
prerelease: false
|
148
154
|
version_requirements: !ruby/object:Gem::Requirement
|
149
155
|
requirements:
|
150
156
|
- - "~>"
|
151
157
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
158
|
+
version: '3.0'
|
153
159
|
- !ruby/object:Gem::Dependency
|
154
160
|
name: redcarpet
|
155
161
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,15 +204,17 @@ description: |-
|
|
198
204
|
status, and a variety of metrics including memory consumption, open file counts, and more.
|
199
205
|
email: "<sensu-users@googlegroups.com>"
|
200
206
|
executables:
|
201
|
-
-
|
207
|
+
- check-solr-replication-lag.rb
|
202
208
|
- metrics-solr-v1.4graphite.rb
|
203
209
|
- metrics-solr4-graphite.rb
|
210
|
+
- metrics-solr-graphite.rb
|
204
211
|
extensions: []
|
205
212
|
extra_rdoc_files: []
|
206
213
|
files:
|
207
214
|
- CHANGELOG.md
|
208
215
|
- LICENSE
|
209
216
|
- README.md
|
217
|
+
- bin/check-solr-replication-lag.rb
|
210
218
|
- bin/metrics-solr-graphite.rb
|
211
219
|
- bin/metrics-solr-v1.4graphite.rb
|
212
220
|
- bin/metrics-solr4-graphite.rb
|
@@ -237,8 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
245
|
- !ruby/object:Gem::Version
|
238
246
|
version: '0'
|
239
247
|
requirements: []
|
240
|
-
|
241
|
-
rubygems_version: 2.4.5
|
248
|
+
rubygems_version: 3.1.2
|
242
249
|
signing_key:
|
243
250
|
specification_version: 4
|
244
251
|
summary: Sensu plugins for solr
|