Class: Vmpooler::API::Dashboard
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Vmpooler::API::Dashboard
- Defined in:
- lib/vmpooler/api/dashboard.rb
Instance Method Summary collapse
- #backend ⇒ Object
-
#config ⇒ Object
handle to the App’s configuration information.
-
#graph_link(target = '') ⇒ Object
return a full URL to a viewable graph for a given metrics target (graphite syntax).
-
#graph_prefix ⇒ Object
configuration setting for URL prefix for graphs to view.
-
#graph_server ⇒ Object
configuration setting for server hosting graph URLs to view.
-
#graph_url ⇒ Object
what is the base URL for viewable graphs?.
Instance Method Details
#backend ⇒ Object
15 16 17 |
# File 'lib/vmpooler/api/dashboard.rb', line 15 def backend Vmpooler::API.settings.redis end |
#config ⇒ Object
handle to the App’s configuration information
11 12 13 |
# File 'lib/vmpooler/api/dashboard.rb', line 11 def config @config ||= Vmpooler::API.settings.config end |
#graph_link(target = '') ⇒ Object
return a full URL to a viewable graph for a given metrics target (graphite syntax)
61 62 63 64 65 |
# File 'lib/vmpooler/api/dashboard.rb', line 61 def graph_link(target = '') return '' unless graph_url graph_url + target end |
#graph_prefix ⇒ Object
configuration setting for URL prefix for graphs to view
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vmpooler/api/dashboard.rb', line 37 def graph_prefix return @graph_prefix if @graph_prefix if config[:graphs] return 'vmpooler' unless config[:graphs]['prefix'] @graph_prefix = config[:graphs]['prefix'] elsif config[:graphite] return false unless config[:graphite]['prefix'] @graph_prefix = config[:graphite]['prefix'] else false end end |
#graph_server ⇒ Object
configuration setting for server hosting graph URLs to view
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vmpooler/api/dashboard.rb', line 20 def graph_server return @graph_server if @graph_server if config[:graphs] return false unless config[:graphs]['server'] @graph_server = config[:graphs]['server'] elsif config[:graphite] return false unless config[:graphite]['server'] @graph_server = config[:graphite]['server'] else false end end |
#graph_url ⇒ Object
what is the base URL for viewable graphs?
54 55 56 57 58 |
# File 'lib/vmpooler/api/dashboard.rb', line 54 def graph_url return false unless graph_server && graph_prefix @graph_url ||= "http://#{graph_server}/render?target=#{graph_prefix}" end |