From f9c5f300e46e786de95abcb5bbaa7ae6cedd588a Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Tue, 12 Jun 2018 00:30:15 +0300 Subject: add mtime and bump up version Fixes performance regression --- lib/oxidized/node.rb | 5 +++++ lib/oxidized/node/stats.rb | 6 ++++++ lib/oxidized/version.rb | 4 ++-- lib/oxidized/worker.rb | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/oxidized/node.rb b/lib/oxidized/node.rb index 3c32b8e..300221e 100644 --- a/lib/oxidized/node.rb +++ b/lib/oxidized/node.rb @@ -95,6 +95,7 @@ module Oxidized :model => @model.class.to_s, :last => nil, :vars => @vars, + :mtime => @stats.mtime, } h[:full_name] = [@group, @name].join('/') if @group if @last @@ -126,6 +127,10 @@ module Oxidized @retry = 0 end + def modified + @stats.update_mtime + end + private def resolve_prompt opt diff --git a/lib/oxidized/node/stats.rb b/lib/oxidized/node/stats.rb index 0778d6d..fbc2cf7 100644 --- a/lib/oxidized/node/stats.rb +++ b/lib/oxidized/node/stats.rb @@ -1,6 +1,7 @@ module Oxidized class Node class Stats + attr_accessor :mtime MAX_STAT = 10 # @param [Job] job job whose information add to stats @@ -35,9 +36,14 @@ module Oxidized @stats[:counter].reduce(0) { |m, h| h[0] == :success ? m : m + h[1] } end + def update_mtime + @mtime = Time.now.utc + end + private def initialize + @mtime = "unknown" @stats = {} @stats[:counter] = Hash.new 0 end diff --git a/lib/oxidized/version.rb b/lib/oxidized/version.rb index 397ae5e..4b710ef 100644 --- a/lib/oxidized/version.rb +++ b/lib/oxidized/version.rb @@ -1,6 +1,6 @@ module Oxidized - VERSION = '0.22.0' - VERSION_FULL = '0.22.0-10-ge8bee7b' + VERSION = '0.23.0' + VERSION_FULL = '0.23.0' def self.version_set version_full = %x(git describe --tags).chop rescue "" version = %x(git describe --tags --abbrev=0).chop rescue "" diff --git a/lib/oxidized/worker.rb b/lib/oxidized/worker.rb index 5d5fc01..74b046d 100644 --- a/lib/oxidized/worker.rb +++ b/lib/oxidized/worker.rb @@ -53,6 +53,7 @@ module Oxidized output = node.output.new if output.store node.name, job.config, :msg => msg, :email => node.email, :user => node.user, :group => node.group + node.modified Oxidized.logger.info "Configuration updated for #{node.group}/#{node.name}" Oxidized.Hooks.handle :post_store, :node => node, :job => job, -- cgit v1.2.1