summaryrefslogtreecommitdiff
path: root/lib/oxidized
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2015-02-21 16:23:22 +0200
committerSaku Ytti <saku@ytti.fi>2015-02-21 16:23:22 +0200
commitba2d48b5d4f7bf8fa657ba4c59416250cf6caca7 (patch)
treebfb947db8715f2b9ddbe40b918eba979b009a28f /lib/oxidized
parent61c128c95ffbcdff0e379d8b005c287db54c5cc3 (diff)
Increase rolling average view
Previously view was 2 nodes, so if average was 7s then some node took 1000s your average would be 503.5s. Now we're looking rolling average of each node, which might not be wise either, perhaps I should limit it to last 100 or 1000 nodes. Since we really don't want another place where we have potentially unbounded amount of state...
Diffstat (limited to 'lib/oxidized')
-rw-r--r--lib/oxidized/jobs.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/oxidized/jobs.rb b/lib/oxidized/jobs.rb
index 6476744..0511b49 100644
--- a/lib/oxidized/jobs.rb
+++ b/lib/oxidized/jobs.rb
@@ -1,17 +1,17 @@
module Oxidized
class Jobs < Array
- attr_accessor :interval, :duration, :max, :want
+ attr_accessor :interval, :max, :want
def initialize max, interval, nodes
@max = max
- #@interval = interval * 60
@interval = interval
@nodes = nodes
- @duration = 4
+ @durations = Array.new(@nodes.size, 5) # guess that nodes take 5s
new_count
super()
end
def duration last
- @duration = (@duration + last) / 2
+ @durations.push(last).shift
+ @duration = @durations.inject(:+).to_f / @nodes.size #rolling average
new_count
end
def new_count
@@ -20,5 +20,8 @@ module Oxidized
@want = @nodes.size if @want > @nodes.size
@want = @max if @want > @max
end
+ def add_job
+ @want += 1
+ end
end
end