module Proxy::Monitoring::Icinga2::Common
Private Instance Methods
with_event_counter(log_prefix, interval_count = 100, interval_seconds = 60) { || ... }
click to toggle source
# File lib/smart_proxy_monitoring_icinga2/monitoring_icinga2_common.rb, line 5 def with_event_counter(log_prefix, interval_count = 100, interval_seconds = 60) semaphore.synchronize do @counter ||= 0 @timer ||= Time.now if @counter >= interval_count || (Time.now - @timer) > interval_seconds status = "#{log_prefix}: Observed #{@counter} events in the last #{(Time.now - @timer).round(2)} seconds." status += " #{@queue.length} items queued. #{@queue.num_waiting} threads waiting." unless @queue.nil? logger.info status @timer = Time.now @counter = 0 end @counter += 1 end yield end