class LitmusPaper::Metric::SocketUtilization

Attributes

maxconn[R]
weight[R]

Public Class Methods

new(weight, maxconn) click to toggle source
# File lib/litmus_paper/metric/socket_utilization.rb, line 8
def initialize(weight, maxconn)
  @weight = weight
  @maxconn = maxconn
end

Public Instance Methods

_stats() click to toggle source
# File lib/litmus_paper/metric/socket_utilization.rb, line 39
def _stats
  raise "Sub-classes must implement _stats"
end
current_health() click to toggle source
# File lib/litmus_paper/metric/socket_utilization.rb, line 13
def current_health
  stats = _stats

  if stats.queued == 0
    return weight
  end

  [
    weight - (
      (weight * stats.active.to_f) / (3 * maxconn.to_f) +
      (2 * weight * stats.queued.to_f) / (3 * maxconn.to_f)
    ),
    1
  ].max
end
stats() click to toggle source
# File lib/litmus_paper/metric/socket_utilization.rb, line 29
def stats
  stats = _stats

  {
    :socket_active => stats.active,
    :socket_queued => stats.queued,
    :socket_utilization => ((stats.queued / maxconn.to_f) * 100).round,
  }
end
to_s() click to toggle source
# File lib/litmus_paper/metric/socket_utilization.rb, line 43
def to_s
  raise "Sub-classes must implement to_s"
end