summaryrefslogtreecommitdiff
path: root/lib/oxidized/nodes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/nodes.rb')
-rw-r--r--lib/oxidized/nodes.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb
index 46630b8..2ea1891 100644
--- a/lib/oxidized/nodes.rb
+++ b/lib/oxidized/nodes.rb
@@ -32,7 +32,7 @@ module Oxidized
Log.error "node %s is not resolvable, raised %s with message '%s'" % [node, err.class, err.message]
end
end
- replace new
+ size == 0 ? replace(new) : update_nodes(new)
end
end
@@ -124,5 +124,24 @@ module Oxidized
Nodes.new :nodes => select { |node| not node.running? }
end
+ # walks list of new nodes, if old node contains same name, adds last and
+ # stats information from old to new.
+ #
+ # @todo can we trust name to be unique identifier, what about when groups are used?
+ # @param [Array] nodes Array of nodes used to replace+update old
+ def update_nodes nodes
+ old = self.dup
+ replace(nodes)
+ each do |node|
+ begin
+ if i = old.find_node_index(node.name)
+ node.stats = old[i].stats
+ node.last = old[i].last
+ end
+ rescue Oxidized::NodeNotFound
+ end
+ end
+ end
+
end
end