Class: Synapse::Easy::Section::Stats

Inherits:
Base
  • Object
show all
Defined in:
lib/synapse/easy/section/stats.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#address, #mode, #name, #options, #port, #type

Instance Method Summary collapse

Methods inherited from Base

#bind, #each, #to_synapse

Constructor Details

#initialize(params = {}) ⇒ Stats

Returns a new instance of Stats.



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

def initialize params={}
  super
  @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

#enabledObject

Returns the value of attribute enabled.



9
10
11
# File 'lib/synapse/easy/section/stats.rb', line 9

def enabled
  @enabled
end

#hide_versionObject

Returns the value of attribute hide_version.



9
10
11
# File 'lib/synapse/easy/section/stats.rb', line 9

def hide_version
  @hide_version
end

#nodeObject

Returns the value of attribute node.



9
10
11
# File 'lib/synapse/easy/section/stats.rb', line 9

def node
  @node
end

#passwordObject

Returns the value of attribute password.



9
10
11
# File 'lib/synapse/easy/section/stats.rb', line 9

def password
  @password
end

#realmObject

Returns the value of attribute realm.



9
10
11
# File 'lib/synapse/easy/section/stats.rb', line 9

def realm
  @realm
end

#refreshObject

Returns the value of attribute refresh.



9
10
11
# File 'lib/synapse/easy/section/stats.rb', line 9

def refresh
  @refresh
end

#scopeObject

Returns the value of attribute scope.



9
10
11
# File 'lib/synapse/easy/section/stats.rb', line 9

def scope
  @scope
end

#show_nodeObject

Returns the value of attribute show_node.



9
10
11
# File 'lib/synapse/easy/section/stats.rb', line 9

def show_node
  @show_node
end

#uriObject

Returns the value of attribute uri.



9
10
11
# File 'lib/synapse/easy/section/stats.rb', line 9

def uri
  @uri
end

#usernameObject

Returns the value of attribute username.



9
10
11
# File 'lib/synapse/easy/section/stats.rb', line 9

def username
  @username
end

Instance Method Details

#labelObject



44
45
46
# File 'lib/synapse/easy/section/stats.rb', line 44

def label
  "listen stats #{bind}"
end

#section_optionsObject



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/synapse/easy/section/stats.rb', line 31

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