From 8cef62390cdfbff723e2d6b99fd92157406e17d5 Mon Sep 17 00:00:00 2001 From: Mike Bryant Date: Wed, 27 Jan 2016 14:42:58 +0000 Subject: If a reload operation changes the number of nodes, ensure @durations is updated Otherwise the average duration calculation will be wrong --- lib/oxidized/jobs.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/oxidized') diff --git a/lib/oxidized/jobs.rb b/lib/oxidized/jobs.rb index 60a83f4..2c656f6 100644 --- a/lib/oxidized/jobs.rb +++ b/lib/oxidized/jobs.rb @@ -20,6 +20,11 @@ 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 -- cgit v1.2.1