summaryrefslogtreecommitdiff
path: root/lib/oxidized
diff options
context:
space:
mode:
authorNeil Lathwood <neil@lathwood.co.uk>2017-10-31 21:38:54 +0000
committerlaf <neil@lathwood.co.uk>2017-11-10 13:06:40 +0000
commitd156ac397beffabe3f0cb045f923050a3ab74887 (patch)
tree0ba404a38da0bca728ba6340303973c201d55ee4 /lib/oxidized
parentf720682514df9f49d35e6ced8af41e5dc789f8e0 (diff)
Added support for sending single node request to http source
Diffstat (limited to 'lib/oxidized')
-rw-r--r--lib/oxidized/nodes.rb3
-rw-r--r--lib/oxidized/source/http.rb8
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb
index 3f84e15..84cf956 100644
--- a/lib/oxidized/nodes.rb
+++ b/lib/oxidized/nodes.rb
@@ -12,7 +12,8 @@ module Oxidized
@source = Oxidized.config.source.default
Oxidized.mgr.add_source @source
Oxidized.logger.info "lib/oxidized/nodes.rb: Loading nodes"
- Oxidized.mgr.source[@source].new.load.each do |node|
+ nodes = Oxidized.mgr.source[@source].new.load node_want
+ nodes.each do |node|
# we want to load specific node(s), not all of them
next unless node_want? node_want, node
begin
diff --git a/lib/oxidized/source/http.rb b/lib/oxidized/source/http.rb
index 6c12f29..e4cb58e 100644
--- a/lib/oxidized/source/http.rb
+++ b/lib/oxidized/source/http.rb
@@ -15,7 +15,7 @@ class HTTP < Source
require "uri"
require "json"
- def load
+ def load node=nil
nodes = []
uri = URI.parse(@cfg.url)
http = Net::HTTP.new(uri.host, uri.port)
@@ -28,7 +28,11 @@ class HTTP < Source
headers[header] = value
end
- request = Net::HTTP::Get.new(uri.request_uri, headers)
+ req_uri = uri.request_uri
+ if node
+ req_uri = "#{req_uri}/#{node}"
+ end
+ request = Net::HTTP::Get.new(req_uri, headers)
if (@cfg.user? && @cfg.pass?)
request.basic_auth(@cfg.user,@cfg.pass)
end