Class: Synapse::Easy::StatsSection

Inherits:
ExtraSection show all
Defined in:
lib/synapse/easy/stats_section.rb

Instance Attribute Summary collapse

Attributes inherited from ExtraSection

#name, #options, #type

Instance Method Summary collapse

Methods inherited from ExtraSection

#each, #to_synapse

Constructor Details

#initialize(params = {}) ⇒ StatsSection

Returns a new instance of StatsSection.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/synapse/easy/stats_section.rb', line 11

def initialize params={}
  super
  @address        = params[:address]
  @address      ||= "localhost"
  @port           = params[:port]
  @port         ||= Freeport.port
  @uri            = params[:uri]
  @uri          ||= "/"
  @enabled        = params[:enabled]
  @enabled      ||= true if @enabled.nil?
  @refresh        = params[:refresh]
  @refresh      ||= 5
  @realm          = params[:realm]
  @realm        ||= "HAProxy\\ Stats"
  @hide_version   = params[:hide_version]
  @hide_version ||= true if @hide_version.nil?
  @username       = params[:username]
  @password       = params[:password]
  @scope          = params[:scope]
  @show_node      = params[:show_node]
  @show_node    ||= false if @show_node.nil?
  @node           = params[:node]
  @node         ||= Socket.gethostname
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



8
9
10
# File 'lib/synapse/easy/stats_section.rb', line 8

def address
  @address
end

#enabledObject

Returns the value of attribute enabled.



8
9
10
# File 'lib/synapse/easy/stats_section.rb', line 8

def enabled
  @enabled
end

#hide_versionObject

Returns the value of attribute hide_version.



8
9
10
# File 'lib/synapse/easy/stats_section.rb', line 8

def hide_version
  @hide_version
end

#nodeObject

Returns the value of attribute node.



8
9
10
# File 'lib/synapse/easy/stats_section.rb', line 8

def node
  @node
end

#passwordObject

Returns the value of attribute password.



8
9
10
# File 'lib/synapse/easy/stats_section.rb', line 8

def password
  @password
end

#portObject

Returns the value of attribute port.



8
9
10
# File 'lib/synapse/easy/stats_section.rb', line 8

def port
  @port
end

#realmObject

Returns the value of attribute realm.



8
9
10
# File 'lib/synapse/easy/stats_section.rb', line 8

def realm
  @realm
end

#refreshObject

Returns the value of attribute refresh.



8
9
10
# File 'lib/synapse/easy/stats_section.rb', line 8

def refresh
  @refresh
end

#scopeObject

Returns the value of attribute scope.



8
9
10
# File 'lib/synapse/easy/stats_section.rb', line 8

def scope
  @scope
end

#show_nodeObject

Returns the value of attribute show_node.



8
9
10
# File 'lib/synapse/easy/stats_section.rb', line 8

def show_node
  @show_node
end

#uriObject

Returns the value of attribute uri.



8
9
10
# File 'lib/synapse/easy/stats_section.rb', line 8

def uri
  @uri
end

#usernameObject

Returns the value of attribute username.



8
9
10
# File 'lib/synapse/easy/stats_section.rb', line 8

def username
  @username
end

Instance Method Details

#bindObject



48
49
50
# File 'lib/synapse/easy/stats_section.rb', line 48

def bind
  [address,port].compact.join(":")
end

#labelObject



51
52
53
# File 'lib/synapse/easy/stats_section.rb', line 51

def label
  "listen stats #{bind}"
end

#section_optionsObject



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/synapse/easy/stats_section.rb', line 35

def section_options
  @options + [
      "mode http",
    ( "stats enable" if enabled ),
      "stats uri #{uri}",
      "stats refresh #{refresh}",
      "stats realm #{realm}",
    ( "stats hide-version" if hide_version),
    ( "stats auth #{username}:#{password}" if username and password ),
    ( "stats scope #{scope}" if scope ),
    ( "stats show-node #{node}" if show_node ),
  ].compact
end