From 219c4527ab0bab5243e5a979e1c8eb6126fcd128 Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Tue, 12 Jun 2018 18:39:05 +0300 Subject: allow configurable history size in stats --- lib/oxidized/node/stats.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/oxidized/node/stats.rb') diff --git a/lib/oxidized/node/stats.rb b/lib/oxidized/node/stats.rb index e50f799..6ea8985 100644 --- a/lib/oxidized/node/stats.rb +++ b/lib/oxidized/node/stats.rb @@ -13,7 +13,7 @@ module Oxidized :time => job.time, } @stats[job.status] ||= [] - @stats[job.status].shift if @stats[job.status].size > MAX_STAT + @stats[job.status].shift if @stats[job.status].size > @history_size @stats[job.status].push stat @stats[:counter][job.status] += 1 end @@ -48,7 +48,8 @@ module Oxidized private def initialize - @mtimes = Array.new(MAX_STAT, "unknown") + @history_size = Oxidized.config.stats.history_size? || MAX_STAT + @mtimes = Array.new(@history_size, "unknown") @stats = {} @stats[:counter] = Hash.new 0 end -- cgit v1.2.1