Class: Monitors::ViolationsRecorders::ResponseTime

Inherits:
Base
  • Object
show all
Defined in:
lib/monitors/violations_recorders/response_time.rb

Class Method Summary collapse

Methods inherited from Base

inherited, is_violating?, reset

Methods included from Logging

#log, #logger

Class Method Details

.process_attrObject



12
13
14
# File 'lib/monitors/violations_recorders/response_time.rb', line 12

def process_attr
  :pid
end

.process_is_violating?(process) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/monitors/violations_recorders/response_time.rb', line 16

def process_is_violating?(process)
  time = Cfg.response_time_threshold 
  phrase = nil
  begin 
    Timeout.timeout(Cfg.response_time_threshold) do 
      response = get_response(process)
      time = response.split("***").last.to_f
      phrase = response.match(Cfg.response_check_phrase)
    end
  rescue Timeout::Error
    return true
  end
  ( time > Cfg.response_time_threshold ) || !(phrase)
end

.retries_limitObject



8
9
10
# File 'lib/monitors/violations_recorders/response_time.rb', line 8

def retries_limit
  Cfg.response_time_check_retries
end