summaryrefslogtreecommitdiff
path: root/lib/oxidized
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized')
-rw-r--r--lib/oxidized/jobs.rb7
-rw-r--r--lib/oxidized/nodes.rb1
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/oxidized/jobs.rb b/lib/oxidized/jobs.rb
index ff7f92b..2c656f6 100644
--- a/lib/oxidized/jobs.rb
+++ b/lib/oxidized/jobs.rb
@@ -20,13 +20,18 @@ module Oxidized
end
def duration last
+ if @durations.size > @nodes.size
+ @durations.slice! @nodes.size...@durations.size
+ elsif @durations.size < @nodes.size
+ @durations.fill AVERAGE_DURATION, @durations.size...@nodes.size
+ end
@durations.push(last).shift
@duration = @durations.inject(:+).to_f / @nodes.size #rolling average
new_count
end
def new_count
- @want = ((@nodes.size * @duration) / @interval).to_i
+ @want = ((@nodes.size * @duration) / @interval).ceil
@want = 1 if @want < 1
@want = @nodes.size if @want > @nodes.size
@want = @max if @want > @max
diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb
index 0c02d7a..61d2d44 100644
--- a/lib/oxidized/nodes.rb
+++ b/lib/oxidized/nodes.rb
@@ -147,6 +147,7 @@ module Oxidized
rescue Oxidized::NodeNotFound
end
end
+ sort_by! { |x| x.last.nil? ? Time.new(0) : x.last.end }
end
public