diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f92e714 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +/.bundle/ +/.yardoc +/Gemfile.lock +/_yardoc/ +/coverage/ +/doc/ +/pkg/ +/spec/reports/ +/tmp/ +*.bundle +*.so +*.o +*.a +mkmf.log +.vagrant/* +.DS_Store +.idea/* +*.gem diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..8011955 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,25 @@ + +MethodLength: + Max: 200 + +LineLength: + Max: 160 + +FileName: + Enabled: false + +PerceivedComplexity: + Enabled: false + +CyclomaticComplexity: + Enabled: false + +ClassLength: + Enabled: false + +IfUnlessModifier: + Enabled: false + +RegexpLiteral: + Enabled: false + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..95ba777 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +language: ruby +cache: + - bundler +install: + - bundle install +rvm: + - 1.9.3 + - 2.0 + - 2.1 +notifications: + email: + recipients: + - mattjones@yieldbot.com + on_success: change + on_failure: always + +script: + - 'bundle exec rake default' diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..f8c9a53 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1 @@ +#### 0.0.1.alpha.1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..ba15939 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1 @@ +[Development Documentation](http://sensu-plugins.github.io/development/) diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..fa75df1 --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gemspec diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6a08171 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2015 devops@yieldbot.com + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..1b155e8 --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +## Sensu-Plugins-solr + +[![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-solr.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-solr) +[![Gem Version](https://badge.fury.io/rb/sensu-plugins-solr.svg)](http://badge.fury.io/rb/sensu-plugins-solr) +[![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-solr/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-solr) +[![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-solr/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-solr) +[![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-solr.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-solr) + +## Functionality + +## Files + * bin/metrics-solr-graphite + * metrics-solr-v1.4graphite + * bin/metrics-solr4-graphite + * + +## Usage + +## Installation + +Add the public key (if you haven’t already) as a trusted certificate + +``` +gem cert --add <(curl -Ls https://raw.githubusercontent.com/sensu-plugins/sensu-plugins.github.io/master/certs/sensu-plugins.pem) +gem install sensu-plugins-solr -P MediumSecurity +``` + +You can also download the key from /certs/ within each repository. + +#### Rubygems + +`gem install sensu-plugins-solr` + +#### Bundler + +Add *sensu-plugins-disk-checks* to your Gemfile and run `bundle install` or `bundle update` + +#### Chef + +Using the Sensu **sensu_gem** LWRP +``` +sensu_gem 'sensu-plugins-solr' do + options('--prerelease') + version '0.0.1' +end +``` + +Using the Chef **gem_package** resource +``` +gem_package 'sensu-plugins-solr' do + options('--prerelease') + version '0.0.1' +end +``` + +## Notes diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..5ce0c83 --- /dev/null +++ b/Rakefile @@ -0,0 +1,35 @@ +require 'bundler/gem_tasks' +require 'rspec/core/rake_task' +require 'yard' +require 'github/markup' +require 'rubocop/rake_task' +require 'redcarpet' +require 'yard/rake/yardoc_task' + +desc 'Don\'t run Rubocop for unsupported versions' +begin + if RUBY_VERSION >= '2.0.0' + args = [:spec, :make_bin_executable, :yard, :rubocop] + else + args = [:spec, :make_bin_executable, :yard] + end +end + +YARD::Rake::YardocTask.new do |t| + OTHER_PATHS = %w() + t.files = ['lib/**/*.rb', 'bin/**/*.rb', OTHER_PATHS] + t.options = %w(--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md) +end + +Rubocop::RakeTask.new + +RSpec::Core::RakeTask.new(:spec) do |r| + r.pattern = FileList['**/**/*_spec.rb'] +end + +desc 'Make all plugins executable' +task :make_bin_executable do + `chmod -R +x bin/***/*.rb` +end + +task default: args diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..033525b --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,32 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +VAGRANTFILE_API_VERSION = '2' + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + config.vm.box = 'chef/centos-6.6' + config.vm.box_download_checksum = true + config.vm.box_download_checksum_type = 'md5' + config.vm.hostname = 'sensu-plugins-dev' + + script = < +# +# Released under the same terms as Sensu (the MIT license); see LICENSE +# for details. + +require 'rubygems' if RUBY_VERSION < '1.9.0' +require 'sensu-plugin/metric/cli' +require 'net/http' +require 'json' +require 'uri' +require 'crack' + +class SolrGraphite < Sensu::Plugin::Metric::CLI::Graphite + option :host, + short: '-h HOST', + long: '--host HOST', + description: 'Solr Host to connect to', + required: true + + option :port, + short: '-p PORT', + long: '--port PORT', + description: 'Solr Port to connect to', + proc: proc(&:to_i), + required: true + + option :core, + description: 'Solr Core to check', + short: '-c CORE', + long: '--core CORE', + default: nil + + option :scheme, + description: 'Metric naming scheme, text to prepend to metric', + short: '-s SCHEME', + long: '--scheme SCHEME', + default: "#{Socket.gethostname}.solr" + + def run + cores = [] + if config[:core] + cores = [config[:core]] + else + # If no core is specified, provide statistics for all cores + status_url = "http://#{config[:host]}:#{config[:port]}/solr/admin/cores?action=STATUS&wt=json" + status_resp = Net::HTTP.get_response(URI.parse(status_url)) + status = JSON.parse(status_resp.body) + cores = status['status'].keys + end + + cores.each do |core| + + if config[:core] + # Don't include core name in scheme to match previous functionality + graphitepath = config[:scheme] + else + graphitepath = "#{config[:scheme]}.#{core}" + end + ping_url = "http://#{config[:host]}:#{config[:port]}/solr/#{core}/admin/ping?wt=json" + + resp = Net::HTTP.get_response(URI.parse(ping_url)) + ping = JSON.parse(resp.body) + + output "#{graphitepath}.solr.QueryTime", ping['responseHeader']['QTime'] + output "#{graphitepath}.solr.Status", ping['responseHeader']['status'] + + stats_url = "http://#{config[:host]}:#{config[:port]}/solr/#{core}/admin/stats.jsp" + + xml_data = Net::HTTP.get_response(URI.parse(stats_url)).body.gsub("\n", '') + stats = Crack::XML.parse(xml_data) + + # this xml is an ugly beast. + core_searcher = stats['solr']['solr_info']['CORE']['entry'].select { |v| v['name'].strip! == 'searcher' }.first['stats']['stat'] + standard = stats['solr']['solr_info']['QUERYHANDLER']['entry'].select { |v| v['name'].strip! == 'standard' }.first['stats']['stat'] + update = stats['solr']['solr_info']['QUERYHANDLER']['entry'].select { |v| v['name'] == '/update' }.first['stats']['stat'] + updatehandler = stats['solr']['solr_info']['UPDATEHANDLER']['entry']['stats']['stat'] + querycache = stats['solr']['solr_info']['CACHE']['entry'].select { |v| v['name'].strip! == 'queryResultCache' }.first['stats']['stat'] + documentcache = stats['solr']['solr_info']['CACHE']['entry'].select { |v| v['name'] == 'documentCache' }.first['stats']['stat'] + filtercache = stats['solr']['solr_info']['CACHE']['entry'].select { |v| v['name'] == 'filterCache' }.first['stats']['stat'] + + output "#{graphitepath}.core.maxdocs", core_searcher[2].strip! + output "#{graphitepath}.core.maxdocs", core_searcher[3].strip! + output "#{graphitepath}.core.warmuptime", core_searcher[9].strip! + + output "#{graphitepath}.queryhandler.standard.requests", standard[1].strip! + output "#{graphitepath}.queryhandler.standard.errors", standard[2].strip! + output "#{graphitepath}.queryhandler.standard.timeouts", standard[3].strip! + output "#{graphitepath}.queryhandler.standard.totaltime", standard[4].strip! + output "#{graphitepath}.queryhandler.standard.timeperrequest", standard[5].strip! + output "#{graphitepath}.queryhandler.standard.requestspersecond", standard[6].strip! + + output "#{graphitepath}.queryhandler.update.requests", update[1].strip! + output "#{graphitepath}.queryhandler.update.errors", update[2].strip! + output "#{graphitepath}.queryhandler.update.timeouts", update[3].strip! + output "#{graphitepath}.queryhandler.update.totaltime", update[4].strip! + output "#{graphitepath}.queryhandler.update.timeperrequest", update[5].strip! + output "#{graphitepath}.queryhandler.update.requestspersecond", standard[6].strip! + + output "#{graphitepath}.queryhandler.updatehandler.commits", updatehandler[0].strip! + output "#{graphitepath}.queryhandler.updatehandler.autocommits", updatehandler[3].strip! + output "#{graphitepath}.queryhandler.updatehandler.optimizes", updatehandler[4].strip! + output "#{graphitepath}.queryhandler.updatehandler.rollbacks", updatehandler[5].strip! + output "#{graphitepath}.queryhandler.updatehandler.docspending", updatehandler[7].strip! + output "#{graphitepath}.queryhandler.updatehandler.adds", updatehandler[8].strip! + output "#{graphitepath}.queryhandler.updatehandler.errors", updatehandler[11].strip! + output "#{graphitepath}.queryhandler.updatehandler.cumulativeadds", updatehandler[12].strip! + output "#{graphitepath}.queryhandler.updatehandler.cumulativeerrors", updatehandler[15].strip! + + output "#{graphitepath}.queryhandler.querycache.lookups", querycache[0].strip! + output "#{graphitepath}.queryhandler.querycache.hits", querycache[1].strip! + output "#{graphitepath}.queryhandler.querycache.hitRatio", querycache[2].strip! + output "#{graphitepath}.queryhandler.querycache.inserts", querycache[3].strip! + output "#{graphitepath}.queryhandler.querycache.size", querycache[5].strip! + output "#{graphitepath}.queryhandler.querycache.warmuptime", querycache[6].strip! + output "#{graphitepath}.queryhandler.querycache.cumulativelookups", querycache[7].strip! + output "#{graphitepath}.queryhandler.querycache.cumulativehits", querycache[8].strip! + output "#{graphitepath}.queryhandler.querycache.cumulativehitratio", querycache[9].strip! + output "#{graphitepath}.queryhandler.querycache.cumulativeinserts", querycache[10].strip! + + output "#{graphitepath}.queryhandler.documentcache.lookups", documentcache[0].strip! + output "#{graphitepath}.queryhandler.documentcache.hits", documentcache[1].strip! + output "#{graphitepath}.queryhandler.documentcache.hitRatio", documentcache[2].strip! + output "#{graphitepath}.queryhandler.documentcache.inserts", documentcache[3].strip! + output "#{graphitepath}.queryhandler.documentcache.size", documentcache[5].strip! + output "#{graphitepath}.queryhandler.documentcache.warmuptime", documentcache[6].strip! + output "#{graphitepath}.queryhandler.documentcache.cumulativelookups", documentcache[7].strip! + output "#{graphitepath}.queryhandler.documentcache.cumulativehits", documentcache[8].strip! + output "#{graphitepath}.queryhandler.documentcache.cumulativehitratio", documentcache[9].strip! + output "#{graphitepath}.queryhandler.documentcache.cumulativeinserts", documentcache[10].strip! + + output "#{graphitepath}.queryhandler.filtercache.lookups", filtercache[0].strip! + output "#{graphitepath}.queryhandler.filtercache.hits", filtercache[1].strip! + output "#{graphitepath}.queryhandler.filtercache.hitRatio", filtercache[2].strip! + output "#{graphitepath}.queryhandler.filtercache.inserts", filtercache[3].strip! + output "#{graphitepath}.queryhandler.filtercache.size", filtercache[5].strip! + output "#{graphitepath}.queryhandler.filtercache.warmuptime", filtercache[6].strip! + output "#{graphitepath}.queryhandler.filtercache.cumulativelookups", filtercache[7].strip! + output "#{graphitepath}.queryhandler.filtercache.cumulativehits", filtercache[8].strip! + output "#{graphitepath}.queryhandler.filtercache.cumulativehitratio", filtercache[9].strip! + output "#{graphitepath}.queryhandler.filtercache.cumulativeinserts", documentcache[10].strip! + end + + ok + end +end diff --git a/bin/metrics-solr-v1.4graphite.rb b/bin/metrics-solr-v1.4graphite.rb new file mode 100644 index 0000000..ffcad60 --- /dev/null +++ b/bin/metrics-solr-v1.4graphite.rb @@ -0,0 +1,95 @@ +#!/usr/bin/env ruby +# Created by Mike Crocker +# Grab various metrics from apache-solr stats page +# +require 'rubygems' if RUBY_VERSION < '1.9.0' +require 'sensu-plugin/metric/cli' +require 'socket' +require 'nokogiri' +require 'open-uri' + +class SolrGraphite < Sensu::Plugin::Metric::CLI::Graphite + option :host, + short: '-h HOST', + long: '--host HOST', + description: 'Solr host to connect to', + default: "#{Socket.gethostname}" + + option :port, + short: '-p PORT', + long: '--port PORT', + description: 'Solr port to connect', + proc: proc(&:to_i), + required: true + + option :scheme, + short: '-s SCHEME', + long: '--scheme', + default: "#{Socket.gethostname}" + + def lookingfor(needle, haystack) + haystack.each_with_index do |element, index| + if element.css('name').text.strip == needle + return index + else + next + end + end + end + + def outputstats(section, queryindex, statpage, metrics, label) + metrics.each do |value| + 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 + # 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| + output [config[:scheme], 'CORE', coreinfo.css('name').text.strip, 'numDocs'].join('.'), coreinfo.css("stats stat[name='numDocs']").text.strip, \ + Time.now.to_i + output [config[:scheme], 'CORE', coreinfo.css('name').text.strip, 'maxDoc'].join('.'), coreinfo.css("stats stat[name='maxDoc']").text.strip, Time.now.to_i + output [config[:scheme], 'CORE', coreinfo.css('name').text.strip, 'warmupTime'].join('.'), coreinfo.css("stats stat[name='warmupTime']").text.strip, \ + Time.now.to_i + end + + # 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_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'] + statupdatehand = Array['commits', 'autocommits', 'optimizes', 'rollbacks', 'docsPending', 'adds', 'errors', 'cumulative_adds', \ + 'cumulative_errors'] + statcache = Array['lookups', 'hits', 'hitratio', 'inserts', 'size', 'warmupTime', 'cumulative_lookups', 'cumulative_hits', \ + 'cumulative_hitratio', 'cumulative_inserts'] + + name = doc.css('QUERYHANDLER entry')[ind_standard].css('name').text.strip + outputstats('QUERYHANDLER', ind_standard, doc, statqueryhand, name) + + name = doc.css('QUERYHANDLER entry')[ind_update].css('name').text.strip + outputstats('QUERYHANDLER', ind_update, doc, statqueryhand, name) + + name = doc.css('UPDATEHANDLER entry')[ind_update_hand].css('name').text.strip + outputstats('UPDATEHANDLER', ind_update_hand, doc, statupdatehand, name) + + name = doc.css('CACHE entry')[ind_cache].css('name').text.strip + outputstats('CACHE', ind_cache, doc, statcache, name) + + name = doc.css('CACHE entry')[ind_doc_cache].css('name').text.strip + outputstats('CACHE', ind_doc_cache, doc, statcache, name) + + name = doc.css('CACHE entry')[ind_fil_cache].css('name').text.strip + outputstats('CACHE', ind_fil_cache, doc, statcache, name) + + ok + end +end diff --git a/bin/metrics-solr4-graphite.rb b/bin/metrics-solr4-graphite.rb new file mode 100755 index 0000000..038caff --- /dev/null +++ b/bin/metrics-solr4-graphite.rb @@ -0,0 +1,123 @@ +#!/usr/bin/env ruby +# +# Push Apache Solr stats into graphite +# === +# +# TODO: Flags to narrow down needed stats only +# +# Copyright 2013 Kyle Burckhard +# +# Released under the same terms as Sensu (the MIT license); see LICENSE +# for details. + +require 'rubygems' if RUBY_VERSION < '1.9.0' +require 'sensu-plugin/metric/cli' +require 'rest-client' +require 'json' + +class Solr4Graphite < Sensu::Plugin::Metric::CLI::Graphite + option :host, + short: '-h HOST', + long: '--host HOST', + description: 'Solr Host to connect to', + required: true + + option :port, + short: '-p PORT', + long: '--port PORT', + description: 'Solr Port to connect to', + proc: proc(&:to_i), + required: true + + option :scheme, + description: 'Metric naming scheme, text to prepend to metric', + short: '-s SCHEME', + long: '--scheme SCHEME', + default: "#{Socket.gethostname}.solr" + + def get_url_json(url) + r = RestClient::Resource.new(url, timeout: 45) + JSON.parse(r.get) + rescue Errno::ECONNREFUSED + warning 'Connection refused' + rescue RestClient::RequestTimeout + warning 'Connection timed out' + rescue RestClient::ResourceNotFound + warning "404 resource not found - #{url}" + rescue => e + warning "RestClient exception: #{e.class} -> #{e.message}" + end + + def run + graphite_path = config[:scheme] + + # Process core stats + core_json = get_url_json "http://#{config[:host]}:#{config[:port]}/solr/admin/cores?stats=true&wt=json" + + output "#{graphite_path}.Status", core_json['responseHeader']['status'] + output "#{graphite_path}.QueryTime", core_json['responseHeader']['QTime'] + + # Process system stats + first_core = core_json['status'].keys.first + + sys_json = get_url_json "http://#{config[:host]}:#{config[:port]}/solr/#{first_core}/admin/system?stats=true&wt=json" + sys_json['jvm']['memory']['raw'].each do |stat, value| + output "#{graphite_path}.jvm.memory.#{stat}", value + end + output "#{graphite_path}.system.openFileCount", sys_json['system']['openFileDescriptorCount'] + output "#{graphite_path}.system.maxFileCount", sys_json['system']['maxFileDescriptorCount'] + + core_json['status'].keys.each do |core| + graphite_path = "#{config[:scheme]}.#{core}" + mbeans_json = get_url_json "http://#{config[:host]}:#{config[:port]}/solr/#{core}/admin/mbeans?stats=true&wt=json" + + output "#{graphite_path}.Status", mbeans_json['responseHeader']['status'] + output "#{graphite_path}.QueryTime", mbeans_json['responseHeader']['QTime'] + + mbeans_json['solr-mbeans'] = Hash[*mbeans_json['solr-mbeans']] + + collection = mbeans_json['solr-mbeans']['CORE']['core']['stats']['collection'] + shard = mbeans_json['solr-mbeans']['CORE']['core']['stats']['shard'] + + graphite_path += ".#{collection}.#{shard}" + + mbeans_json['solr-mbeans']['CORE']['searcher']['stats'].each do |stat, value| + output "#{graphite_path}.searcher.#{stat}", value if value.is_a?(Numeric) + end + + # query handler stats + { + '/update' => 'updates', + '/query' => 'queries', + '/select' => 'selects', + '/replication' => 'replication' + }.each do |hash_node, graphite_node| + next unless mbeans_json['solr-mbeans']['QUERYHANDLER'][hash_node] + mbeans_json['solr-mbeans']['QUERYHANDLER'][hash_node]['stats'].each do |stat, value| + output "#{graphite_path}.queryHandler.#{graphite_node}.#{stat}", value if value.is_a?(Numeric) + output "#{graphite_path}.queryHandler.replication.#{stat}", (value.to_f * 1_073_741_824).to_i if value =~ /\d+\.?\d* GB/ + end + end + + mbeans_json['solr-mbeans']['UPDATEHANDLER']['updateHandler']['stats'].each do |stat, value| + output "#{graphite_path}.updateHandler.#{stat.gsub(' ', '_')}", value if value.is_a?(Numeric) + end + + # cache stats + { + 'queryResultCache' => 'queryResults', + 'fieldCache' => 'fields', + 'documentCache' => 'documents', + 'fieldValueCache' => 'fieldValues', + 'filterCache' => 'filters' + }.each do |hash_node, graphite_node| + next unless mbeans_json['solr-mbeans']['CACHE'][hash_node] + mbeans_json['solr-mbeans']['CACHE'][hash_node]['stats'].each do |stat, value| + output "#{graphite_path}.cache.#{graphite_node}.#{stat}", value if value.is_a?(Numeric) + end + end + end + + ok + end +end diff --git a/certs/sensu-plugins.pem b/certs/sensu-plugins.pem new file mode 100644 index 0000000..955a0e5 --- /dev/null +++ b/certs/sensu-plugins.pem @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRIwEAYDVQQDDAltYXR0 +am9uZXMxGDAWBgoJkiaJk/IsZAEZFgh5aWVsZGJvdDETMBEGCgmSJomT8ixkARkW +A2NvbTAeFw0xNTAxMjgyMTAyNTFaFw0xNjAxMjgyMTAyNTFaMEMxEjAQBgNVBAMM +CW1hdHRqb25lczEYMBYGCgmSJomT8ixkARkWCHlpZWxkYm90MRMwEQYKCZImiZPy +LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyTSzVYnO +CLgyrIyT1mBQakArQyW8xhi6MlDqyzXHJGeERT790U6EgoBVeS4XoK0ptFZNR8Tf +zko0w+Nv47TarSCgkPOaxY+mxWnAVR10dOmfeLr7huiMyps+YD56/EF2FqQ3jf/+ +qohENfKD91qy1ieEy+Fn7Pf74ltbNKUdkb9a9eFXQ0DQ4ip5vik7DzjQkUTj4lca +k6ArwnmHX4YDhZoYtrQJ8jVktN0/+NtA40M5qkCYHNe5tUW25b/tKVYuioxG6b2Z +oIzaZxRLxf6HVAWpCVRT/F5+/yjigkX4u++eYacfLGleXQzoK7BL65vHGMJygWEE +0TKGqFOrl/L0AQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV +HQ4EFgQUEf6a8Td7MrSZc8ImbLFZAENPbz0wIQYDVR0RBBowGIEWbWF0dGpvbmVz +QHlpZWxkYm90LmNvbTAhBgNVHRIEGjAYgRZtYXR0am9uZXNAeWllbGRib3QuY29t +MA0GCSqGSIb3DQEBBQUAA4IBAQBbzXAYA3BVGw8DZ0YYoY1VHPNEcH5qPIApmHO8 +rvSmuUT0yMEi7u00H/5uHRFf4LleGT/+sTdyXKsNPGT9kdRuQEgwi+vf7Zfvd8aX +UF/+4VkEYf/8rV8Ere6u2QaWPgApdMV6JjKr1fAwCTd8AuGXNaWItiPPMseSQzLJ +JKP4hVvbc1d+oS925B1lcBiqn2aYvElbyNAVmQPywNNqkWmvtlqj9ZVJfV5HQLdu +8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk +HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr +-----END CERTIFICATE----- diff --git a/lib/sensu-plugins-solr.rb b/lib/sensu-plugins-solr.rb new file mode 100644 index 0000000..07ab87a --- /dev/null +++ b/lib/sensu-plugins-solr.rb @@ -0,0 +1,7 @@ +# +# Set gem version +# +module SensuPluginsSolr + # Gem version + VERSION = '0.0.1.alpha.1' +end diff --git a/sensu-plugins-solr.gemspec b/sensu-plugins-solr.gemspec new file mode 100644 index 0000000..372a044 --- /dev/null +++ b/sensu-plugins-solr.gemspec @@ -0,0 +1,46 @@ +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) + +require 'date' + + +if RUBY_VERSION < '2.0.0' + require 'sensu-plugins-solr' +else + require_relative 'lib/sensu-plugins-solr' +end + +pvt_key = '~/.ssh/gem-private_key.pem' + +Gem::Specification.new do |s| + s.name = 'sensu-plugins-solr' + s.version = SensuPluginsSolr::VERSION + s.authors = ["Yieldbot, Inc. and contributors"] + s.email = '' + s.homepage = 'https://github.com/sensu-plugins/sensu-plugins-solr' + s.summary = '' + s.description = '' + s.license = 'MIT' + s.date = Date.today.to_s + s.files = Dir.glob('{bin,lib}/**/*') + %w(LICENSE README.md CHANGELOG.md) + s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) } + s.test_files = s.files.grep(%r{^(test|spec|features)/}) + s.require_paths = ["lib"] + s.cert_chain = ["certs/sensu-plugins.pem"] + s.signing_key = File.expand_path(pvt_key) if $PROGRAM_NAME =~ /gem\z/ + s.platform = Gem::Platform::RUBY + s.required_ruby_version = '>= 1.9.3' + + + s.add_runtime_dependency 'sensu-plugin' + + s.add_development_dependency 'codeclimate-test-reporter' + s.add_development_dependency 'rubocop', '~> 0.17.0' + s.add_development_dependency 'rspec', '~> 3.1' + s.add_development_dependency 'bundler', '~> 1.7' + s.add_development_dependency 'rake', '~> 10.0' + s.add_development_dependency 'github-markup' + s.add_development_dependency 'redcarpet' + s.add_development_dependency 'yard' + s.add_development_dependency 'pry' +end diff --git a/test/spec_helper.rb b/test/spec_helper.rb new file mode 100644 index 0000000..9797982 --- /dev/null +++ b/test/spec_helper.rb @@ -0,0 +1,2 @@ +require 'codeclimate-test-reporter' +CodeClimate::TestReporter.start