diff options
author | ytti <saku@ytti.fi> | 2018-04-27 13:57:27 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-27 13:57:27 +0300 |
commit | 1311573a1adff6edf2c0b3cfdb05ca83d6c46e73 (patch) | |
tree | 5d5d8e916a7a12c1e29bc2b5e6b31805eabaa0d8 /lib/oxidized/source | |
parent | 34fd5369feee94ab45c5a81d7769b1df717e4c8c (diff) | |
parent | 137314377bbc15b651228a0394caf45e6fa8bcbc (diff) |
Merge pull request #1095 from laf/feature/oxs-single-host
feature Allow oxs to call for single host
Diffstat (limited to 'lib/oxidized/source')
-rw-r--r-- | lib/oxidized/source/http.rb | 8 | ||||
-rw-r--r-- | lib/oxidized/source/sql.rb | 7 |
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 = {} |