bin/riemann-riak in riemann-tools-0.1.3 vs bin/riemann-riak in riemann-tools-0.1.4
- old
+ new
@@ -3,16 +3,17 @@
# Forwards information on a Riak node to Riemann.
require File.expand_path('../../lib/riemann/tools', __FILE__)
require 'net/http'
+require 'net/https'
require 'yajl/json_gem'
class Riemann::Tools::Riak
include Riemann::Tools
- opt :riak_host, "Riak host", :default => Socket.gethostname
+ opt :riak_host, "Riak host for stats <IP> or SSL http(s)://<IP>", :default => Socket.gethostname
opt :data_dir, "Riak data directory", :default => '/var/lib/riak'
opt :stats_port, "Riak HTTP port for stats", :default => 8098
opt :stats_path, "Riak HTTP stats path", :default => '/stats'
opt :node_name, "Riak erlang node name", :default => "riak@#{Socket.gethostname}"
opt :cookie, "Riak cookie to use", :default => "riak"
@@ -37,22 +38,31 @@
@riakadmin = false
end
if
begin
- Net::HTTP.start(opts[:riak_host], opts[:stats_port]) do |http|
- http.get opts[:stats_path]
+ uri = URI.parse(opts[:riak_host])
+ if uri.host == nil
+ uri.host = opts[:riak_host]
end
+ http = Net::HTTP.new(uri.host, opts[:stats_port])
+ http.use_ssl = uri.scheme == 'https'
+ if http.use_ssl?
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+ end
+ http.start do |http|
+ http.get opts[:stats_path]
+ end
rescue => e
@httpstatus = false
end
end
# we're going to override the emulator setting to allow users to
# dynamically input the cookie
# this is done only once - hopefully it doesn't get overridden.
ENV['ERL_AFLAGS'] = "-setcookie #{opts[:cookie]}"
-
+
end
def check_ring
if @escript
str = `#{File.expand_path(File.dirname(__FILE__))}/riemann-riak-ring #{opts[:node_name]}`.chomp
@@ -127,12 +137,21 @@
end
def check_stats
if @httpstatus
begin
- res = Net::HTTP.start(opts[:riak_host], opts[:stats_port]) do |http|
- http.get opts[:stats_path]
+ uri = URI.parse(opts[:riak_host])
+ if uri.host == nil
+ uri.host = opts[:riak_host]
end
+ http = Net::HTTP.new(uri.host, opts[:stats_port])
+ http.use_ssl = uri.scheme == 'https'
+ if http.use_ssl?
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+ end
+ res = http.start do |http|
+ http.get opts[:stats_path]
+ end
rescue => e
report(
:host => opts[:riak_host],
:service => 'riak',
:state => 'critical',