class Stats::Worker

Public Class Methods

new(wstats) click to toggle source
# File lib/stats.rb, line 4
def initialize(wstats)
  @wstats = wstats
end

Public Instance Methods

backlog() click to toggle source
# File lib/stats.rb, line 76
def backlog
  @wstats.dig('last_status', 'backlog') || 0
end
booting?() click to toggle source
# File lib/stats.rb, line 36
def booting?
  @wstats.key?('last_status') && @wstats['last_status'].empty?
end
killed=(killed) click to toggle source
# File lib/stats.rb, line 12
def killed=(killed)
  @wstats['killed'] = killed
end
killed?() click to toggle source
# File lib/stats.rb, line 16
def killed?
  !!@wstats['killed']
end
last_checkin() click to toggle source
# File lib/stats.rb, line 80
def last_checkin
  (Time.now - Time.parse(@wstats['last_checkin'])).round
rescue
  0
end
load() click to toggle source
# File lib/stats.rb, line 63
def load
  running_threads/total_threads.to_f*100
end
max_threads() click to toggle source
# File lib/stats.rb, line 46
def max_threads
  @wstats.dig('last_status', 'max_threads') || @wstats['max_threads'] || 0
end
Also aliased as: total_threads
mem() click to toggle source
# File lib/stats.rb, line 24
def mem
  @wstats['mem']
end
mem=(mem) click to toggle source
# File lib/stats.rb, line 20
def mem=(mem)
  @wstats['mem'] = mem
end
pcpu() click to toggle source
# File lib/stats.rb, line 32
def pcpu
  @wstats['pcpu']
end
pcpu=(pcpu) click to toggle source
# File lib/stats.rb, line 28
def pcpu=(pcpu)
  @wstats['pcpu'] = pcpu
end
phase() click to toggle source
# File lib/stats.rb, line 59
def phase
  @wstats['phase']
end
pid() click to toggle source
# File lib/stats.rb, line 8
def pid
  @wstats['pid']
end
pool_capacity() click to toggle source
# File lib/stats.rb, line 51
def pool_capacity
  @wstats.dig('last_status', 'pool_capacity') || @wstats['pool_capacity'] || 0
end
requests_count() click to toggle source
# File lib/stats.rb, line 72
def requests_count
  @wstats.dig('last_status', 'requests_count') || @wstats['requests_count']
end
running() click to toggle source
# File lib/stats.rb, line 40
def running
  @wstats.dig('last_status', 'running') || @wstats['running'] || 0
end
Also aliased as: total_threads, spawned_threads
running_threads() click to toggle source
# File lib/stats.rb, line 55
def running_threads
  max_threads - pool_capacity
end
spawned_threads()
Alias for: running
total_threads()
Alias for: running
uptime() click to toggle source
# File lib/stats.rb, line 67
def uptime
  return 0 unless @wstats.key?('started_at')
  (Time.now - Time.parse(@wstats['started_at'])).to_i
end