Class: LitmusPaper::Metric::TcpSocketUtilization

Inherits:
SocketUtilization show all
Defined in:
lib/litmus_paper/metric/tcp_socket_utilization.rb

Instance Attribute Summary collapse

Attributes inherited from SocketUtilization

#maxconn, #weight

Instance Method Summary collapse

Methods inherited from SocketUtilization

#current_health, #stats

Constructor Details

#initialize(weight, address, maxconn) ⇒ TcpSocketUtilization

Returns a new instance of TcpSocketUtilization.



8
9
10
11
# File 'lib/litmus_paper/metric/tcp_socket_utilization.rb', line 8

def initialize(weight, address, maxconn)
  super(weight, maxconn)
  @address = address
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



6
7
8
# File 'lib/litmus_paper/metric/tcp_socket_utilization.rb', line 6

def address
  @address
end

Instance Method Details

#_statsObject



13
14
15
# File 'lib/litmus_paper/metric/tcp_socket_utilization.rb', line 13

def _stats
  Raindrops::Linux.tcp_listener_stats([address])[address]
end

#to_sObject



17
18
19
20
21
22
23
24
# File 'lib/litmus_paper/metric/tcp_socket_utilization.rb', line 17

def to_s
  current_stats = stats
  active = current_stats[:socket_active]
  queued = current_stats[:socket_queued]
  utilization = current_stats[:socket_utilization]

  "Metric::TcpSocketUtilization(weight: #{weight}, maxconn: #{maxconn}, active: #{active}, queued: #{queued}, utilization: #{utilization}, address: #{address})"
end