class Sponges::Response

Attributes

supervisor[R]

Public Class Methods

new(supervisor) click to toggle source
# File lib/sponges/response.rb, line 6
def initialize(supervisor)
  @supervisor = supervisor
end

Public Instance Methods

as_json(opts={}) click to toggle source
# File lib/sponges/response.rb, line 14
def as_json(opts={})
  {
    supervisor: process_information(supervisor.pid),
    children: children_information
  }
end
to_json() click to toggle source
# File lib/sponges/response.rb, line 10
def to_json
  as_json.to_json
end

Private Instance Methods

children_information() click to toggle source
# File lib/sponges/response.rb, line 34
def children_information
  supervisor.children_pids.map do |pid|
    process_information(pid)
  end
end
process_information(pid) click to toggle source
# File lib/sponges/response.rb, line 23
def process_information(pid)
  info = Machine::ProcessStatus.new(pid)
  {
    pid:         pid,
    pctcpu:      info.pctcpu,
    pctmem:      info.pctmem,
    created_at:  info.created_at

  }
end