Class: Cloudscale::Monitor::InitCharts
- Inherits:
-
Object
- Object
- Cloudscale::Monitor::InitCharts
- Defined in:
- lib/cloudscale/monitor/agent/init_charts.rb
Instance Attribute Summary collapse
-
#agentInstanceId ⇒ Object
Returns the value of attribute agentInstanceId.
-
#client ⇒ Object
Returns the value of attribute client.
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#log ⇒ Object
Returns the value of attribute log.
-
#server ⇒ Object
Returns the value of attribute server.
Instance Method Summary collapse
- #init_chart(chart, agentInstanceId) ⇒ Object
-
#initialize(agentInstanceId, path) ⇒ InitCharts
constructor
A new instance of InitCharts.
Constructor Details
#initialize(agentInstanceId, path) ⇒ InitCharts
Returns a new instance of InitCharts.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cloudscale/monitor/agent/init_charts.rb', line 17 def initialize(agentInstanceId, path) if (agentInstanceId == nil) raise "InitCharts.new(): AgentInstanceId may not be null" end @log = Logger.new(STDOUT) @log.info("Initializing Charts") @client = RestClientWrapper.instance file = File.read(path); plugin = YAML.load(JSON.parse(file).to_yaml) plugin.each do | key, value | init_chart(value, agentInstanceId) end end |
Instance Attribute Details
#agentInstanceId ⇒ Object
Returns the value of attribute agentInstanceId.
15 16 17 |
# File 'lib/cloudscale/monitor/agent/init_charts.rb', line 15 def agentInstanceId @agentInstanceId end |
#client ⇒ Object
Returns the value of attribute client.
15 16 17 |
# File 'lib/cloudscale/monitor/agent/init_charts.rb', line 15 def client @client end |
#customer ⇒ Object
Returns the value of attribute customer.
15 16 17 |
# File 'lib/cloudscale/monitor/agent/init_charts.rb', line 15 def customer @customer end |
#log ⇒ Object
Returns the value of attribute log.
15 16 17 |
# File 'lib/cloudscale/monitor/agent/init_charts.rb', line 15 def log @log end |
#server ⇒ Object
Returns the value of attribute server.
15 16 17 |
# File 'lib/cloudscale/monitor/agent/init_charts.rb', line 15 def server @server end |
Instance Method Details
#init_chart(chart, agentInstanceId) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cloudscale/monitor/agent/init_charts.rb', line 33 def init_chart(chart, agentInstanceId) chart["agentInstanceId"] = agentInstanceId chart["queries"].each { | query | query["command"].sub! '[[agentInstanceId]]', agentInstanceId } test_chart = @client.searchOne("charts", "findByAgentInstanceIdAndChartId", { :agentInstanceId => agentInstanceId, :chartId => chart["chartId"]}) if (test_chart == nil) client.post("charts", chart) else client.patch("charts", RestClientWrapper.load_entity_id(test_chart), chart) end end |