bin/metrics-solr-v1.4graphite.rb in sensu-plugins-solr-0.0.3 vs bin/metrics-solr-v1.4graphite.rb in sensu-plugins-solr-1.0.0
- old
+ new
@@ -10,11 +10,11 @@
class SolrGraphite < Sensu::Plugin::Metric::CLI::Graphite
option :host,
short: '-h HOST',
long: '--host HOST',
description: 'Solr host to connect to',
- default: "#{Socket.gethostname}"
+ default: Socket.gethostname.to_s
option :port,
short: '-p PORT',
long: '--port PORT',
description: 'Solr port to connect',
@@ -22,15 +22,15 @@
required: true
option :scheme,
short: '-s SCHEME',
long: '--scheme',
- default: "#{Socket.gethostname}"
+ default: Socket.gethostname.to_s
def lookingfor(needle, haystack)
haystack.each_with_index do |element, index|
- if element.css('name').text.strip == needle
+ if element.css('name').text.strip == needle # rubocop:disable Style/GuardClause
return index
else
next
end
end
@@ -41,11 +41,11 @@
stat = statpage.css("#{section} entry")[queryindex].css("stats stat[name=#{value}]").text.strip
output [config[:scheme], label, value].join('.'), stat, Time.now.to_i
end
end
- def run # rubocop:disable all
+ def run
# Capture initial stats page XML data. Sol4 1.4 takes a while to load stats page, the timeout accomidates that.
doc = Nokogiri::XML(open("http://#{config[:host]}:#{config[:port]}/solr/admin/stats.jsp", read_timeout: 300))
# Go through each core and get the appropriate data
doc.css('CORE entry').each do |coreinfo|
@@ -58,10 +58,10 @@
# Location of particular metric on our XML stat page
ind_standard = lookingfor('standard', doc.css('QUERYHANDLER entry'))
ind_update = lookingfor('/update', doc.css('QUERYHANDLER entry'))
ind_update_hand = lookingfor('updateHandler', doc.css('UPDATEHANDLER entry'))
- ind_cache = lookingfor('queryResultCache', doc.css('CACHE entry'))
+ ind_cache = lookingfor('queryResultCache', doc.css('CACHE entry'))
ind_doc_cache = lookingfor('documentCache', doc.css('CACHE entry'))
ind_fil_cache = lookingfor('filterCache', doc.css('CACHE entry'))
# All the metrics we're looking for
statqueryhand = Array['requests', 'errors', 'timeouts', 'avgTimePerRequest', 'avgRequestsPerSecond']