summaryrefslogtreecommitdiff
path: root/lib/oxidized/nodes.rb
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2014-07-04 10:02:20 +0300
committerSaku Ytti <saku@ytti.fi>2014-07-04 10:02:20 +0300
commitb3bec7b240640b1b6ca900bb3aab3659914783c0 (patch)
tree3e2d86e93efa780a60181f7f093d9113a2a21dfc /lib/oxidized/nodes.rb
parentc8b9e5af6d38e73ffa830c7abc137021447cb6bc (diff)
match node[:name] to ip
When running Oxidized via oxidized-script you want just one node, and you specify that as Nodes.new(:node=>x) however as router.db usually lacks 'ip' field, and only has 'name' field'. If you have router.db with IP in 'name' field, and you do Nodes.new(:node='192.0.2.1') it won't return anything, as '192.0.2.1' is matched against node[:ip] which does not exist. This change makes IP match against IP and Name.
Diffstat (limited to 'lib/oxidized/nodes.rb')
-rw-r--r--lib/oxidized/nodes.rb8
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb
index 2ea1891..d6cc867 100644
--- a/lib/oxidized/nodes.rb
+++ b/lib/oxidized/nodes.rb
@@ -9,18 +9,14 @@ module Oxidized
def load node_want=nil
with_lock do
new = []
- node_want_ip = (IPAddr.new(node_want) rescue nil) if node_want
+ node_want_ip = (IPAddr.new(node_want) rescue false) if node_want
@source = CFG.source.default
Oxidized.mgr.add_source @source
Oxidized.mgr.source[@source].new.load.each do |node|
# we want to load specific node(s), not all of them
if node_want
- if node_want_ip
- next unless node_want_ip == node[:ip]
- else
- next unless node[:name].match node_want
- end
+ next unless node_want_ip == node[:ip] or node_want.match(node[:name])
end
begin