Class: Abstractive::Esto

Inherits:
Actor
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/abstractive/esto.rb

Constant Summary collapse

MONITORS =
{
  uptime: 90,
  thread_survey: 30,
  thread_report: 15,
  thread_summary: 3,
  memory_count: 13,
  threads_and_memory: 45
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Esto

Returns a new instance of Esto.



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/abstractive/esto.rb', line 29

def initialize(options={})
  @semaphor = {}
  @status = {}
  @timers = {}
  @short = options.fetch(:short, false)
  @debug = options.fetch(:debug, false)
  @logger = options.fetch(:logger, nil)
  @declare = options.fetch(:declare, false)
  @intervals = MONITORS.dup
  @options = options
  @running = Hitimes::Interval.now
  async.start
end

Class Method Details

.start!(options = {}) ⇒ Object



13
14
15
16
17
# File 'lib/abstractive/esto.rb', line 13

def start!(options={})
  name = options.delete(:name) || :esto
  Abstractive::Esto.supervise(as: name, args: [options])
  Celluloid[name]
end

Instance Method Details

#memory_count!Object



77
78
79
# File 'lib/abstractive/esto.rb', line 77

def memory_count!
  trigger!(:memory_count) { console memory }
end

#startObject



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/abstractive/esto.rb', line 43

def start
  if @options[:monitors].is_a?(Array)
    debug("Monitors:") if @debug
    @options[:monitors].each { |monitor|
      debug("* #{monitor} every #{readable_duration(MONITORS[monitor])}.") if @debug
      send("start_#{monitor}!")
    }
  else
    debug("No preconfigured monitors.") if @debug
  end
end

#thread_report!Object



89
90
91
# File 'lib/abstractive/esto.rb', line 89

def thread_report!
  trigger!(:thread_report) { console threads }
end

#thread_summary!Object



85
86
87
# File 'lib/abstractive/esto.rb', line 85

def thread_summary!
  trigger!(:thread_summary) { print " #{Thread.list.count} " }
end

#thread_survey!Object



81
82
83
# File 'lib/abstractive/esto.rb', line 81

def thread_survey!
  trigger!(:thread_survey) { Celluloid.stack_summary }
end

#threads_and_memory!Object



93
94
95
# File 'lib/abstractive/esto.rb', line 93

def threads_and_memory!
  trigger!(:threads_and_memory) { console "#{threads}; #{memory}" }
end

#uptime!Object



73
74
75
# File 'lib/abstractive/esto.rb', line 73

def uptime!
  trigger!(:uptime) { console "#{(@short ? "U" : "Uptime")}: #{readable_duration(@running.duration_so_far)}" }
end