sensu-plugins-solr 0.0.1
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 +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +12 -0
- data/LICENSE +22 -0
- data/README.md +25 -0
- data/bin/metrics-solr-graphite.rb +150 -0
- data/bin/metrics-solr-v1.4graphite.rb +94 -0
- data/bin/metrics-solr4-graphite.rb +122 -0
- data/lib/sensu-plugins-solr.rb +15 -0
- data/lib/sensu-plugins-solr/version.rb +28 -0
- metadata +275 -0
- metadata.gz.sig +2 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7cfd3cc372afbca52855f7492a22669e1c0d696d
|
4
|
+
data.tar.gz: 7962ee88557f2c50509d37b6a2d8d85e3b9ba899
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 922f4420258f23655345a33e3e70c058bad9ed947f119a5d27458dff42f23cbaae949851f0b6a054a89d6fb11840a0cab5cc420df12c29aead6164863ec33133
|
7
|
+
data.tar.gz: 1f28f07326cd8dbe0c793a5b6b932167849b378e9ffc4450e0a81256c8b7be1e4f37919f24647706837e0a74432aa6ddb1133947c847a27db49a038f979b8d16
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
Binary file
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#Change Log
|
2
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
3
|
+
|
4
|
+
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
5
|
+
|
6
|
+
## Unreleased][unreleased]
|
7
|
+
|
8
|
+
## 0.0.1 - 2015-05-20
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- initial release
|
12
|
+
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Sensu-Plugins
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
## Sensu-Plugins-solr
|
2
|
+
|
3
|
+
[](https://travis-ci.org/sensu-plugins/sensu-plugins-solr)
|
4
|
+
[](http://badge.fury.io/rb/sensu-plugins-solr)
|
5
|
+
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-solr)
|
6
|
+
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-solr)
|
7
|
+
[](https://gemnasium.com/sensu-plugins/sensu-plugins-solr)
|
8
|
+
[ ](https://codeship.com/projects/79861)
|
9
|
+
|
10
|
+
## Functionality
|
11
|
+
|
12
|
+
## Files
|
13
|
+
* bin/metrics-solr-graphite.rb
|
14
|
+
* metrics-solr-v1.4graphite.rb
|
15
|
+
* bin/metrics-solr4-graphite.rb
|
16
|
+
*
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
[Installation and Setup](https://github.com/sensu-plugins/documentation/blob/master/user_docs/installation_instructions.md)
|
23
|
+
|
24
|
+
|
25
|
+
## Notes
|
@@ -0,0 +1,150 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Push Apache Solr stats into graphite
|
4
|
+
# ===
|
5
|
+
#
|
6
|
+
# TODO: Narrow down needed stats, find a cleaner way to parse the xml
|
7
|
+
#
|
8
|
+
# Copyright 2012 Pete Shima <me@peteshima.com>
|
9
|
+
#
|
10
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
11
|
+
# for details.
|
12
|
+
|
13
|
+
require 'sensu-plugin/metric/cli'
|
14
|
+
require 'net/http'
|
15
|
+
require 'json'
|
16
|
+
require 'uri'
|
17
|
+
require 'crack'
|
18
|
+
|
19
|
+
class SolrGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
20
|
+
option :host,
|
21
|
+
short: '-h HOST',
|
22
|
+
long: '--host HOST',
|
23
|
+
description: 'Solr Host to connect to',
|
24
|
+
required: true
|
25
|
+
|
26
|
+
option :port,
|
27
|
+
short: '-p PORT',
|
28
|
+
long: '--port PORT',
|
29
|
+
description: 'Solr Port to connect to',
|
30
|
+
proc: proc(&:to_i),
|
31
|
+
required: true
|
32
|
+
|
33
|
+
option :core,
|
34
|
+
description: 'Solr Core to check',
|
35
|
+
short: '-c CORE',
|
36
|
+
long: '--core CORE',
|
37
|
+
default: nil
|
38
|
+
|
39
|
+
option :scheme,
|
40
|
+
description: 'Metric naming scheme, text to prepend to metric',
|
41
|
+
short: '-s SCHEME',
|
42
|
+
long: '--scheme SCHEME',
|
43
|
+
default: "#{Socket.gethostname}.solr"
|
44
|
+
|
45
|
+
def run # rubocop:disable all
|
46
|
+
cores = []
|
47
|
+
if config[:core]
|
48
|
+
cores = [config[:core]]
|
49
|
+
else
|
50
|
+
# If no core is specified, provide statistics for all cores
|
51
|
+
status_url = "http://#{config[:host]}:#{config[:port]}/solr/admin/cores?action=STATUS&wt=json"
|
52
|
+
status_resp = Net::HTTP.get_response(URI.parse(status_url))
|
53
|
+
status = JSON.parse(status_resp.body)
|
54
|
+
cores = status['status'].keys
|
55
|
+
end
|
56
|
+
|
57
|
+
cores.each do |core|
|
58
|
+
if config[:core]
|
59
|
+
# Don't include core name in scheme to match previous functionality
|
60
|
+
graphitepath = config[:scheme]
|
61
|
+
else
|
62
|
+
graphitepath = "#{config[:scheme]}.#{core}"
|
63
|
+
end
|
64
|
+
ping_url = "http://#{config[:host]}:#{config[:port]}/solr/#{core}/admin/ping?wt=json"
|
65
|
+
|
66
|
+
resp = Net::HTTP.get_response(URI.parse(ping_url))
|
67
|
+
ping = JSON.parse(resp.body)
|
68
|
+
|
69
|
+
output "#{graphitepath}.solr.QueryTime", ping['responseHeader']['QTime']
|
70
|
+
output "#{graphitepath}.solr.Status", ping['responseHeader']['status']
|
71
|
+
|
72
|
+
stats_url = "http://#{config[:host]}:#{config[:port]}/solr/#{core}/admin/stats.jsp"
|
73
|
+
|
74
|
+
xml_data = Net::HTTP.get_response(URI.parse(stats_url)).body.gsub("\n", '')
|
75
|
+
stats = Crack::XML.parse(xml_data)
|
76
|
+
|
77
|
+
# this xml is an ugly beast.
|
78
|
+
core_searcher = stats['solr']['solr_info']['CORE']['entry'].find { |v| v['name'].strip! == 'searcher' }['stats']['stat']
|
79
|
+
standard = stats['solr']['solr_info']['QUERYHANDLER']['entry'].find { |v| v['name'].strip! == 'standard' }['stats']['stat']
|
80
|
+
update = stats['solr']['solr_info']['QUERYHANDLER']['entry'].find { |v| v['name'] == '/update' }['stats']['stat']
|
81
|
+
updatehandler = stats['solr']['solr_info']['UPDATEHANDLER']['entry']['stats']['stat']
|
82
|
+
querycache = stats['solr']['solr_info']['CACHE']['entry'].find { |v| v['name'].strip! == 'queryResultCache' }['stats']['stat']
|
83
|
+
documentcache = stats['solr']['solr_info']['CACHE']['entry'].find { |v| v['name'] == 'documentCache' }['stats']['stat']
|
84
|
+
filtercache = stats['solr']['solr_info']['CACHE']['entry'].find { |v| v['name'] == 'filterCache' }['stats']['stat']
|
85
|
+
|
86
|
+
output "#{graphitepath}.core.maxdocs", core_searcher[2].strip!
|
87
|
+
output "#{graphitepath}.core.maxdocs", core_searcher[3].strip!
|
88
|
+
output "#{graphitepath}.core.warmuptime", core_searcher[9].strip!
|
89
|
+
|
90
|
+
output "#{graphitepath}.queryhandler.standard.requests", standard[1].strip!
|
91
|
+
output "#{graphitepath}.queryhandler.standard.errors", standard[2].strip!
|
92
|
+
output "#{graphitepath}.queryhandler.standard.timeouts", standard[3].strip!
|
93
|
+
output "#{graphitepath}.queryhandler.standard.totaltime", standard[4].strip!
|
94
|
+
output "#{graphitepath}.queryhandler.standard.timeperrequest", standard[5].strip!
|
95
|
+
output "#{graphitepath}.queryhandler.standard.requestspersecond", standard[6].strip!
|
96
|
+
|
97
|
+
output "#{graphitepath}.queryhandler.update.requests", update[1].strip!
|
98
|
+
output "#{graphitepath}.queryhandler.update.errors", update[2].strip!
|
99
|
+
output "#{graphitepath}.queryhandler.update.timeouts", update[3].strip!
|
100
|
+
output "#{graphitepath}.queryhandler.update.totaltime", update[4].strip!
|
101
|
+
output "#{graphitepath}.queryhandler.update.timeperrequest", update[5].strip!
|
102
|
+
output "#{graphitepath}.queryhandler.update.requestspersecond", standard[6].strip!
|
103
|
+
|
104
|
+
output "#{graphitepath}.queryhandler.updatehandler.commits", updatehandler[0].strip!
|
105
|
+
output "#{graphitepath}.queryhandler.updatehandler.autocommits", updatehandler[3].strip!
|
106
|
+
output "#{graphitepath}.queryhandler.updatehandler.optimizes", updatehandler[4].strip!
|
107
|
+
output "#{graphitepath}.queryhandler.updatehandler.rollbacks", updatehandler[5].strip!
|
108
|
+
output "#{graphitepath}.queryhandler.updatehandler.docspending", updatehandler[7].strip!
|
109
|
+
output "#{graphitepath}.queryhandler.updatehandler.adds", updatehandler[8].strip!
|
110
|
+
output "#{graphitepath}.queryhandler.updatehandler.errors", updatehandler[11].strip!
|
111
|
+
output "#{graphitepath}.queryhandler.updatehandler.cumulativeadds", updatehandler[12].strip!
|
112
|
+
output "#{graphitepath}.queryhandler.updatehandler.cumulativeerrors", updatehandler[15].strip!
|
113
|
+
|
114
|
+
output "#{graphitepath}.queryhandler.querycache.lookups", querycache[0].strip!
|
115
|
+
output "#{graphitepath}.queryhandler.querycache.hits", querycache[1].strip!
|
116
|
+
output "#{graphitepath}.queryhandler.querycache.hitRatio", querycache[2].strip!
|
117
|
+
output "#{graphitepath}.queryhandler.querycache.inserts", querycache[3].strip!
|
118
|
+
output "#{graphitepath}.queryhandler.querycache.size", querycache[5].strip!
|
119
|
+
output "#{graphitepath}.queryhandler.querycache.warmuptime", querycache[6].strip!
|
120
|
+
output "#{graphitepath}.queryhandler.querycache.cumulativelookups", querycache[7].strip!
|
121
|
+
output "#{graphitepath}.queryhandler.querycache.cumulativehits", querycache[8].strip!
|
122
|
+
output "#{graphitepath}.queryhandler.querycache.cumulativehitratio", querycache[9].strip!
|
123
|
+
output "#{graphitepath}.queryhandler.querycache.cumulativeinserts", querycache[10].strip!
|
124
|
+
|
125
|
+
output "#{graphitepath}.queryhandler.documentcache.lookups", documentcache[0].strip!
|
126
|
+
output "#{graphitepath}.queryhandler.documentcache.hits", documentcache[1].strip!
|
127
|
+
output "#{graphitepath}.queryhandler.documentcache.hitRatio", documentcache[2].strip!
|
128
|
+
output "#{graphitepath}.queryhandler.documentcache.inserts", documentcache[3].strip!
|
129
|
+
output "#{graphitepath}.queryhandler.documentcache.size", documentcache[5].strip!
|
130
|
+
output "#{graphitepath}.queryhandler.documentcache.warmuptime", documentcache[6].strip!
|
131
|
+
output "#{graphitepath}.queryhandler.documentcache.cumulativelookups", documentcache[7].strip!
|
132
|
+
output "#{graphitepath}.queryhandler.documentcache.cumulativehits", documentcache[8].strip!
|
133
|
+
output "#{graphitepath}.queryhandler.documentcache.cumulativehitratio", documentcache[9].strip!
|
134
|
+
output "#{graphitepath}.queryhandler.documentcache.cumulativeinserts", documentcache[10].strip!
|
135
|
+
|
136
|
+
output "#{graphitepath}.queryhandler.filtercache.lookups", filtercache[0].strip!
|
137
|
+
output "#{graphitepath}.queryhandler.filtercache.hits", filtercache[1].strip!
|
138
|
+
output "#{graphitepath}.queryhandler.filtercache.hitRatio", filtercache[2].strip!
|
139
|
+
output "#{graphitepath}.queryhandler.filtercache.inserts", filtercache[3].strip!
|
140
|
+
output "#{graphitepath}.queryhandler.filtercache.size", filtercache[5].strip!
|
141
|
+
output "#{graphitepath}.queryhandler.filtercache.warmuptime", filtercache[6].strip!
|
142
|
+
output "#{graphitepath}.queryhandler.filtercache.cumulativelookups", filtercache[7].strip!
|
143
|
+
output "#{graphitepath}.queryhandler.filtercache.cumulativehits", filtercache[8].strip!
|
144
|
+
output "#{graphitepath}.queryhandler.filtercache.cumulativehitratio", filtercache[9].strip!
|
145
|
+
output "#{graphitepath}.queryhandler.filtercache.cumulativeinserts", documentcache[10].strip!
|
146
|
+
end
|
147
|
+
|
148
|
+
ok
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Created by Mike Crocker
|
3
|
+
# Grab various metrics from apache-solr stats page
|
4
|
+
#
|
5
|
+
require 'sensu-plugin/metric/cli'
|
6
|
+
require 'socket'
|
7
|
+
require 'nokogiri'
|
8
|
+
require 'open-uri'
|
9
|
+
|
10
|
+
class SolrGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
11
|
+
option :host,
|
12
|
+
short: '-h HOST',
|
13
|
+
long: '--host HOST',
|
14
|
+
description: 'Solr host to connect to',
|
15
|
+
default: "#{Socket.gethostname}"
|
16
|
+
|
17
|
+
option :port,
|
18
|
+
short: '-p PORT',
|
19
|
+
long: '--port PORT',
|
20
|
+
description: 'Solr port to connect',
|
21
|
+
proc: proc(&:to_i),
|
22
|
+
required: true
|
23
|
+
|
24
|
+
option :scheme,
|
25
|
+
short: '-s SCHEME',
|
26
|
+
long: '--scheme',
|
27
|
+
default: "#{Socket.gethostname}"
|
28
|
+
|
29
|
+
def lookingfor(needle, haystack)
|
30
|
+
haystack.each_with_index do |element, index|
|
31
|
+
if element.css('name').text.strip == needle
|
32
|
+
return index
|
33
|
+
else
|
34
|
+
next
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def outputstats(section, queryindex, statpage, metrics, label)
|
40
|
+
metrics.each do |value|
|
41
|
+
stat = statpage.css("#{section} entry")[queryindex].css("stats stat[name=#{value}]").text.strip
|
42
|
+
output [config[:scheme], label, value].join('.'), stat, Time.now.to_i
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def run # rubocop:disable all
|
47
|
+
# Capture initial stats page XML data. Sol4 1.4 takes a while to load stats page, the timeout accomidates that.
|
48
|
+
doc = Nokogiri::XML(open("http://#{config[:host]}:#{config[:port]}/solr/admin/stats.jsp", read_timeout: 300))
|
49
|
+
|
50
|
+
# Go through each core and get the appropriate data
|
51
|
+
doc.css('CORE entry').each do |coreinfo|
|
52
|
+
output [config[:scheme], 'CORE', coreinfo.css('name').text.strip, 'numDocs'].join('.'), coreinfo.css("stats stat[name='numDocs']").text.strip, \
|
53
|
+
Time.now.to_i
|
54
|
+
output [config[:scheme], 'CORE', coreinfo.css('name').text.strip, 'maxDoc'].join('.'), coreinfo.css("stats stat[name='maxDoc']").text.strip, Time.now.to_i
|
55
|
+
output [config[:scheme], 'CORE', coreinfo.css('name').text.strip, 'warmupTime'].join('.'), coreinfo.css("stats stat[name='warmupTime']").text.strip, \
|
56
|
+
Time.now.to_i
|
57
|
+
end
|
58
|
+
|
59
|
+
# Location of particular metric on our XML stat page
|
60
|
+
ind_standard = lookingfor('standard', doc.css('QUERYHANDLER entry'))
|
61
|
+
ind_update = lookingfor('/update', doc.css('QUERYHANDLER entry'))
|
62
|
+
ind_update_hand = lookingfor('updateHandler', doc.css('UPDATEHANDLER entry'))
|
63
|
+
ind_cache = lookingfor('queryResultCache', doc.css('CACHE entry'))
|
64
|
+
ind_doc_cache = lookingfor('documentCache', doc.css('CACHE entry'))
|
65
|
+
ind_fil_cache = lookingfor('filterCache', doc.css('CACHE entry'))
|
66
|
+
|
67
|
+
# All the metrics we're looking for
|
68
|
+
statqueryhand = Array['requests', 'errors', 'timeouts', 'avgTimePerRequest', 'avgRequestsPerSecond']
|
69
|
+
statupdatehand = Array['commits', 'autocommits', 'optimizes', 'rollbacks', 'docsPending', 'adds', 'errors', 'cumulative_adds', \
|
70
|
+
'cumulative_errors']
|
71
|
+
statcache = Array['lookups', 'hits', 'hitratio', 'inserts', 'size', 'warmupTime', 'cumulative_lookups', 'cumulative_hits', \
|
72
|
+
'cumulative_hitratio', 'cumulative_inserts']
|
73
|
+
|
74
|
+
name = doc.css('QUERYHANDLER entry')[ind_standard].css('name').text.strip
|
75
|
+
outputstats('QUERYHANDLER', ind_standard, doc, statqueryhand, name)
|
76
|
+
|
77
|
+
name = doc.css('QUERYHANDLER entry')[ind_update].css('name').text.strip
|
78
|
+
outputstats('QUERYHANDLER', ind_update, doc, statqueryhand, name)
|
79
|
+
|
80
|
+
name = doc.css('UPDATEHANDLER entry')[ind_update_hand].css('name').text.strip
|
81
|
+
outputstats('UPDATEHANDLER', ind_update_hand, doc, statupdatehand, name)
|
82
|
+
|
83
|
+
name = doc.css('CACHE entry')[ind_cache].css('name').text.strip
|
84
|
+
outputstats('CACHE', ind_cache, doc, statcache, name)
|
85
|
+
|
86
|
+
name = doc.css('CACHE entry')[ind_doc_cache].css('name').text.strip
|
87
|
+
outputstats('CACHE', ind_doc_cache, doc, statcache, name)
|
88
|
+
|
89
|
+
name = doc.css('CACHE entry')[ind_fil_cache].css('name').text.strip
|
90
|
+
outputstats('CACHE', ind_fil_cache, doc, statcache, name)
|
91
|
+
|
92
|
+
ok
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Push Apache Solr stats into graphite
|
4
|
+
# ===
|
5
|
+
#
|
6
|
+
# TODO: Flags to narrow down needed stats only
|
7
|
+
#
|
8
|
+
# Copyright 2013 Kyle Burckhard <kyle@marketfish.com>
|
9
|
+
#
|
10
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
11
|
+
# for details.
|
12
|
+
|
13
|
+
require 'sensu-plugin/metric/cli'
|
14
|
+
require 'rest-client'
|
15
|
+
require 'json'
|
16
|
+
|
17
|
+
class Solr4Graphite < Sensu::Plugin::Metric::CLI::Graphite
|
18
|
+
option :host,
|
19
|
+
short: '-h HOST',
|
20
|
+
long: '--host HOST',
|
21
|
+
description: 'Solr Host to connect to',
|
22
|
+
required: true
|
23
|
+
|
24
|
+
option :port,
|
25
|
+
short: '-p PORT',
|
26
|
+
long: '--port PORT',
|
27
|
+
description: 'Solr Port to connect to',
|
28
|
+
proc: proc(&:to_i),
|
29
|
+
required: true
|
30
|
+
|
31
|
+
option :scheme,
|
32
|
+
description: 'Metric naming scheme, text to prepend to metric',
|
33
|
+
short: '-s SCHEME',
|
34
|
+
long: '--scheme SCHEME',
|
35
|
+
default: "#{Socket.gethostname}.solr"
|
36
|
+
|
37
|
+
def get_url_json(url)
|
38
|
+
r = RestClient::Resource.new(url, timeout: 45)
|
39
|
+
JSON.parse(r.get)
|
40
|
+
rescue Errno::ECONNREFUSED
|
41
|
+
warning 'Connection refused'
|
42
|
+
rescue RestClient::RequestTimeout
|
43
|
+
warning 'Connection timed out'
|
44
|
+
rescue RestClient::ResourceNotFound
|
45
|
+
warning "404 resource not found - #{url}"
|
46
|
+
rescue => e
|
47
|
+
warning "RestClient exception: #{e.class} -> #{e.message}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def run #rubocop:disable all
|
51
|
+
graphite_path = config[:scheme]
|
52
|
+
|
53
|
+
# Process core stats
|
54
|
+
core_json = get_url_json "http://#{config[:host]}:#{config[:port]}/solr/admin/cores?stats=true&wt=json"
|
55
|
+
|
56
|
+
output "#{graphite_path}.Status", core_json['responseHeader']['status']
|
57
|
+
output "#{graphite_path}.QueryTime", core_json['responseHeader']['QTime']
|
58
|
+
|
59
|
+
# Process system stats
|
60
|
+
first_core = core_json['status'].keys.first
|
61
|
+
|
62
|
+
sys_json = get_url_json "http://#{config[:host]}:#{config[:port]}/solr/#{first_core}/admin/system?stats=true&wt=json"
|
63
|
+
sys_json['jvm']['memory']['raw'].each do |stat, value|
|
64
|
+
output "#{graphite_path}.jvm.memory.#{stat}", value
|
65
|
+
end
|
66
|
+
output "#{graphite_path}.system.openFileCount", sys_json['system']['openFileDescriptorCount']
|
67
|
+
output "#{graphite_path}.system.maxFileCount", sys_json['system']['maxFileDescriptorCount']
|
68
|
+
|
69
|
+
core_json['status'].keys.each do |core|
|
70
|
+
graphite_path = "#{config[:scheme]}.#{core}"
|
71
|
+
mbeans_json = get_url_json "http://#{config[:host]}:#{config[:port]}/solr/#{core}/admin/mbeans?stats=true&wt=json"
|
72
|
+
|
73
|
+
output "#{graphite_path}.Status", mbeans_json['responseHeader']['status']
|
74
|
+
output "#{graphite_path}.QueryTime", mbeans_json['responseHeader']['QTime']
|
75
|
+
|
76
|
+
mbeans_json['solr-mbeans'] = Hash[*mbeans_json['solr-mbeans']]
|
77
|
+
|
78
|
+
collection = mbeans_json['solr-mbeans']['CORE']['core']['stats']['collection']
|
79
|
+
shard = mbeans_json['solr-mbeans']['CORE']['core']['stats']['shard']
|
80
|
+
|
81
|
+
graphite_path += ".#{collection}.#{shard}"
|
82
|
+
|
83
|
+
mbeans_json['solr-mbeans']['CORE']['searcher']['stats'].each do |stat, value|
|
84
|
+
output "#{graphite_path}.searcher.#{stat}", value if value.is_a?(Numeric)
|
85
|
+
end
|
86
|
+
|
87
|
+
# query handler stats
|
88
|
+
{
|
89
|
+
'/update' => 'updates',
|
90
|
+
'/query' => 'queries',
|
91
|
+
'/select' => 'selects',
|
92
|
+
'/replication' => 'replication'
|
93
|
+
}.each do |hash_node, graphite_node|
|
94
|
+
next unless mbeans_json['solr-mbeans']['QUERYHANDLER'][hash_node]
|
95
|
+
mbeans_json['solr-mbeans']['QUERYHANDLER'][hash_node]['stats'].each do |stat, value|
|
96
|
+
output "#{graphite_path}.queryHandler.#{graphite_node}.#{stat}", value if value.is_a?(Numeric)
|
97
|
+
output "#{graphite_path}.queryHandler.replication.#{stat}", (value.to_f * 1_073_741_824).to_i if value =~ /\d+\.?\d* GB/
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
mbeans_json['solr-mbeans']['UPDATEHANDLER']['updateHandler']['stats'].each do |stat, value|
|
102
|
+
output "#{graphite_path}.updateHandler.#{stat.gsub(' ', '_')}", value if value.is_a?(Numeric)
|
103
|
+
end
|
104
|
+
|
105
|
+
# cache stats
|
106
|
+
{
|
107
|
+
'queryResultCache' => 'queryResults',
|
108
|
+
'fieldCache' => 'fields',
|
109
|
+
'documentCache' => 'documents',
|
110
|
+
'fieldValueCache' => 'fieldValues',
|
111
|
+
'filterCache' => 'filters'
|
112
|
+
}.each do |hash_node, graphite_node|
|
113
|
+
next unless mbeans_json['solr-mbeans']['CACHE'][hash_node]
|
114
|
+
mbeans_json['solr-mbeans']['CACHE'][hash_node]['stats'].each do |stat, value|
|
115
|
+
output "#{graphite_path}.cache.#{graphite_node}.#{stat}", value if value.is_a?(Numeric)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
ok
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
# encoding: utf-8
|
4
|
+
module SensuPluginsSolr
|
5
|
+
# This defines the version of the gem
|
6
|
+
module Version
|
7
|
+
MAJOR = 0
|
8
|
+
MINOR = 0
|
9
|
+
PATCH = 1
|
10
|
+
|
11
|
+
VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
|
12
|
+
|
13
|
+
NAME = 'sensu-plugins-solr'
|
14
|
+
BANNER = "#{NAME} v%s"
|
15
|
+
|
16
|
+
module_function
|
17
|
+
|
18
|
+
def version
|
19
|
+
format(BANNER, VER_STRING)
|
20
|
+
end
|
21
|
+
|
22
|
+
def json_version
|
23
|
+
{
|
24
|
+
'version' => VER_STRING
|
25
|
+
}.to_json
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,275 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-solr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sensu-Plugins and contributors
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRIwEAYDVQQDDAltYXR0
|
14
|
+
am9uZXMxGDAWBgoJkiaJk/IsZAEZFgh5aWVsZGJvdDETMBEGCgmSJomT8ixkARkW
|
15
|
+
A2NvbTAeFw0xNTAxMjgyMTAyNTFaFw0xNjAxMjgyMTAyNTFaMEMxEjAQBgNVBAMM
|
16
|
+
CW1hdHRqb25lczEYMBYGCgmSJomT8ixkARkWCHlpZWxkYm90MRMwEQYKCZImiZPy
|
17
|
+
LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyTSzVYnO
|
18
|
+
CLgyrIyT1mBQakArQyW8xhi6MlDqyzXHJGeERT790U6EgoBVeS4XoK0ptFZNR8Tf
|
19
|
+
zko0w+Nv47TarSCgkPOaxY+mxWnAVR10dOmfeLr7huiMyps+YD56/EF2FqQ3jf/+
|
20
|
+
qohENfKD91qy1ieEy+Fn7Pf74ltbNKUdkb9a9eFXQ0DQ4ip5vik7DzjQkUTj4lca
|
21
|
+
k6ArwnmHX4YDhZoYtrQJ8jVktN0/+NtA40M5qkCYHNe5tUW25b/tKVYuioxG6b2Z
|
22
|
+
oIzaZxRLxf6HVAWpCVRT/F5+/yjigkX4u++eYacfLGleXQzoK7BL65vHGMJygWEE
|
23
|
+
0TKGqFOrl/L0AQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
|
24
|
+
HQ4EFgQUEf6a8Td7MrSZc8ImbLFZAENPbz0wIQYDVR0RBBowGIEWbWF0dGpvbmVz
|
25
|
+
QHlpZWxkYm90LmNvbTAhBgNVHRIEGjAYgRZtYXR0am9uZXNAeWllbGRib3QuY29t
|
26
|
+
MA0GCSqGSIb3DQEBBQUAA4IBAQBbzXAYA3BVGw8DZ0YYoY1VHPNEcH5qPIApmHO8
|
27
|
+
rvSmuUT0yMEi7u00H/5uHRFf4LleGT/+sTdyXKsNPGT9kdRuQEgwi+vf7Zfvd8aX
|
28
|
+
UF/+4VkEYf/8rV8Ere6u2QaWPgApdMV6JjKr1fAwCTd8AuGXNaWItiPPMseSQzLJ
|
29
|
+
JKP4hVvbc1d+oS925B1lcBiqn2aYvElbyNAVmQPywNNqkWmvtlqj9ZVJfV5HQLdu
|
30
|
+
8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
|
31
|
+
HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2015-05-21 00:00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: sensu-plugin
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.1.0
|
42
|
+
type: :runtime
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.1.0
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: crack
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.4.2
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.4.2
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: json
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.8.2
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.8.2
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: rest-client
|
79
|
+
requirement: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 1.8.0
|
84
|
+
type: :runtime
|
85
|
+
prerelease: false
|
86
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 1.8.0
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: nokogiri
|
93
|
+
requirement: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - '='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 1.6.6.2
|
98
|
+
type: :runtime
|
99
|
+
prerelease: false
|
100
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - '='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 1.6.6.2
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: codeclimate-test-reporter
|
107
|
+
requirement: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0.4'
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0.4'
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: rubocop
|
121
|
+
requirement: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0.30'
|
126
|
+
type: :development
|
127
|
+
prerelease: false
|
128
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0.30'
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: rspec
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '3.1'
|
140
|
+
type: :development
|
141
|
+
prerelease: false
|
142
|
+
version_requirements: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '3.1'
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: bundler
|
149
|
+
requirement: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '1.7'
|
154
|
+
type: :development
|
155
|
+
prerelease: false
|
156
|
+
version_requirements: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - "~>"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '1.7'
|
161
|
+
- !ruby/object:Gem::Dependency
|
162
|
+
name: rake
|
163
|
+
requirement: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '10.0'
|
168
|
+
type: :development
|
169
|
+
prerelease: false
|
170
|
+
version_requirements: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - "~>"
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '10.0'
|
175
|
+
- !ruby/object:Gem::Dependency
|
176
|
+
name: github-markup
|
177
|
+
requirement: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - "~>"
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '1.3'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - "~>"
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '1.3'
|
189
|
+
- !ruby/object:Gem::Dependency
|
190
|
+
name: redcarpet
|
191
|
+
requirement: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - "~>"
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '3.2'
|
196
|
+
type: :development
|
197
|
+
prerelease: false
|
198
|
+
version_requirements: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - "~>"
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '3.2'
|
203
|
+
- !ruby/object:Gem::Dependency
|
204
|
+
name: yard
|
205
|
+
requirement: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - "~>"
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0.8'
|
210
|
+
type: :development
|
211
|
+
prerelease: false
|
212
|
+
version_requirements: !ruby/object:Gem::Requirement
|
213
|
+
requirements:
|
214
|
+
- - "~>"
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: '0.8'
|
217
|
+
- !ruby/object:Gem::Dependency
|
218
|
+
name: pry
|
219
|
+
requirement: !ruby/object:Gem::Requirement
|
220
|
+
requirements:
|
221
|
+
- - "~>"
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: '0.10'
|
224
|
+
type: :development
|
225
|
+
prerelease: false
|
226
|
+
version_requirements: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - "~>"
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0.10'
|
231
|
+
description: Sensu plugins for working with solr
|
232
|
+
email: "<sensu-users@googlegroups.com>"
|
233
|
+
executables: []
|
234
|
+
extensions: []
|
235
|
+
extra_rdoc_files: []
|
236
|
+
files:
|
237
|
+
- CHANGELOG.md
|
238
|
+
- LICENSE
|
239
|
+
- README.md
|
240
|
+
- bin/metrics-solr-graphite.rb
|
241
|
+
- bin/metrics-solr-v1.4graphite.rb
|
242
|
+
- bin/metrics-solr4-graphite.rb
|
243
|
+
- lib/sensu-plugins-solr.rb
|
244
|
+
- lib/sensu-plugins-solr/version.rb
|
245
|
+
homepage: https://github.com/sensu-plugins/sensu-plugins-solr
|
246
|
+
licenses:
|
247
|
+
- MIT
|
248
|
+
metadata:
|
249
|
+
maintainer: ''
|
250
|
+
development_status: active
|
251
|
+
production_status: unstable - testing recommended
|
252
|
+
release_draft: 'false'
|
253
|
+
release_prerelease: 'false'
|
254
|
+
post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
|
255
|
+
in /etc/default/sensu
|
256
|
+
rdoc_options: []
|
257
|
+
require_paths:
|
258
|
+
- lib
|
259
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
260
|
+
requirements:
|
261
|
+
- - ">="
|
262
|
+
- !ruby/object:Gem::Version
|
263
|
+
version: 1.9.3
|
264
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
265
|
+
requirements:
|
266
|
+
- - ">="
|
267
|
+
- !ruby/object:Gem::Version
|
268
|
+
version: '0'
|
269
|
+
requirements: []
|
270
|
+
rubyforge_project:
|
271
|
+
rubygems_version: 2.4.6
|
272
|
+
signing_key:
|
273
|
+
specification_version: 4
|
274
|
+
summary: Sensu plugins for working with solr
|
275
|
+
test_files: []
|
metadata.gz.sig
ADDED