summaryrefslogtreecommitdiff
path: root/lib/oxidized/source
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/source')
-rw-r--r--lib/oxidized/source/http.rb8
-rw-r--r--lib/oxidized/source/sql.rb7
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/oxidized/source/http.rb b/lib/oxidized/source/http.rb
index 4480cbb..55dcd4c 100644
--- a/lib/oxidized/source/http.rb
+++ b/lib/oxidized/source/http.rb
@@ -15,7 +15,7 @@ module Oxidized
require "uri"
require "json"
- def load
+ def load node_want = nil
nodes = []
uri = URI.parse(@cfg.url)
http = Net::HTTP.new(uri.host, uri.port)
@@ -28,7 +28,11 @@ module Oxidized
headers[header] = value
end
- request = Net::HTTP::Get.new(uri.request_uri, headers)
+ req_uri = uri.request_uri
+ if node_want
+ req_uri = "#{req_uri}/#{node_want}"
+ end
+ request = Net::HTTP::Get.new(req_uri, headers)
if (@cfg.user? && @cfg.pass?)
request.basic_auth(@cfg.user, @cfg.pass)
end
diff --git a/lib/oxidized/source/sql.rb b/lib/oxidized/source/sql.rb
index 5737c93..c5fe650 100644
--- a/lib/oxidized/source/sql.rb
+++ b/lib/oxidized/source/sql.rb
@@ -18,11 +18,16 @@ module Oxidized
end
end
- def load
+ def load node_want = nil
nodes = []
db = connect
query = db[@cfg.table.to_sym]
query = query.with_sql(@cfg.query) if @cfg.query?
+
+ if node_want
+ query = query.where(@cfg.map.name.to_sym => node_want)
+ end
+
query.each do |node|
# map node parameters
keys = {}