summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/oxidized/nodes.rb21
-rw-r--r--oxidized.gemspec2
2 files changed, 21 insertions, 2 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
diff --git a/oxidized.gemspec b/oxidized.gemspec
index 7e89ad7..86ef906 100644
--- a/oxidized.gemspec
+++ b/oxidized.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'oxidized'
- s.version = '0.0.57'
+ s.version = '0.0.58'
s.platform = Gem::Platform::RUBY
s.authors = [ 'Saku Ytti' ]
s.email = %w( saku@ytti.fi )