diff options
author | Saku Ytti <saku@ytti.fi> | 2018-06-12 18:39:05 +0300 |
---|---|---|
committer | Saku Ytti <saku@ytti.fi> | 2018-06-12 18:39:05 +0300 |
commit | 219c4527ab0bab5243e5a979e1c8eb6126fcd128 (patch) | |
tree | 554a7330708d19e3cb17a28a06ccc3f1b7b9fb73 /lib | |
parent | da9be642cc26cfa82358eb88c537e79715c75680 (diff) |
allow configurable history size in stats
Diffstat (limited to 'lib')
-rw-r--r-- | lib/oxidized/config.rb | 1 | ||||
-rw-r--r-- | lib/oxidized/node/stats.rb | 5 |
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/oxidized/config.rb b/lib/oxidized/config.rb index 36d9d73..115e035 100644 --- a/lib/oxidized/config.rb +++ b/lib/oxidized/config.rb @@ -35,6 +35,7 @@ module Oxidized asetus.default.models = {} # model level configuration asetus.default.pid = File.join(Oxidized::Config::Root, 'pid') + asetus.default.stats.history_size = 10 asetus.default.input.default = 'ssh, telnet' asetus.default.input.debug = false # or String for session log file asetus.default.input.ssh.secure = false # complain about changed certs 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 |