Class: Cellumon
Constant Summary collapse
- MONITORS =
{ thread_survey: 30, thread_report: 15, thread_summary: 3, memory_count: 13, threads_and_memory: 45 }
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Cellumon
constructor
A new instance of Cellumon.
- #memory_count! ⇒ Object
- #start ⇒ Object
- #thread_report! ⇒ Object
- #thread_summary! ⇒ Object
- #thread_survey! ⇒ Object
- #threads_and_memory! ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Cellumon
Returns a new instance of Cellumon.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cellumon.rb', line 28 def initialize(={}) @semaphor = {} @status = {} @timers = {} @debug = .fetch(:debug, false) @logger = .fetch(:logger, nil) @mark = .fetch(:mark, false) @intervals = MONITORS.dup = async.start end |
Class Method Details
.start!(options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/cellumon.rb', line 9 def start!(={}) name = .delete(:name) || :cellumon unless .fetch(:monitors, nil).is_a? Array puts "Cellumon > No monitors specified" return end Cellumon.supervise(as: name, args: []) Celluloid[name] end |
Instance Method Details
#memory_count! ⇒ Object
70 71 72 |
# File 'lib/cellumon.rb', line 70 def memory_count! trigger!(:memory_count) { console memory } end |
#start ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cellumon.rb', line 40 def start if [:monitors].is_a?(Array) debug("Monitors:") if @debug [:monitors].each { |monitor| debug("* #{monitor} every #{MONITORS[monitor]} seconds.") if @debug send("start_#{monitor}!") } else debug("No preconfigured monitors.") if @debug end end |
#thread_report! ⇒ Object
82 83 84 |
# File 'lib/cellumon.rb', line 82 def thread_report! trigger!(:thread_report) { console threads } end |
#thread_summary! ⇒ Object
78 79 80 |
# File 'lib/cellumon.rb', line 78 def thread_summary! trigger!(:thread_summary) { print " #{Thread.list.count} " } end |
#thread_survey! ⇒ Object
74 75 76 |
# File 'lib/cellumon.rb', line 74 def thread_survey! trigger!(:thread_survey) { Celluloid.stack_summary } end |
#threads_and_memory! ⇒ Object
86 87 88 |
# File 'lib/cellumon.rb', line 86 def threads_and_memory! trigger!(:threads_and_memory) { console "#{threads}; #{memory}" } end |