Class: LitmusPaper::Metric::UnixSocketUtilization

Inherits:
SocketUtilization show all
Defined in:
lib/litmus_paper/metric/unix_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, socket_path, maxconn) ⇒ UnixSocketUtilization

Returns a new instance of UnixSocketUtilization.



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

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

Instance Attribute Details

#socket_pathObject (readonly)

Returns the value of attribute socket_path.



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

def socket_path
  @socket_path
end

Instance Method Details

#_statsObject



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

def _stats
  Raindrops::Linux.unix_listener_stats([socket_path])[socket_path]
end

#to_sObject



17
18
19
20
21
22
23
24
# File 'lib/litmus_paper/metric/unix_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::UnixSocketUtilization(weight: #{weight}, maxconn: #{maxconn}, active: #{active}, queued: #{queued}, utilization: #{utilization}, path: #{socket_path})"
end