From ba2d48b5d4f7bf8fa657ba4c59416250cf6caca7 Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Sat, 21 Feb 2015 16:23:22 +0200 Subject: 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... --- lib/oxidized/jobs.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib') 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 -- cgit v1.2.1