Class: Cloudscale::Preops::Preop
- Inherits:
-
Object
- Object
- Cloudscale::Preops::Preop
show all
- Defined in:
- lib/cloudscale/monitor/preops/preop.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#log ⇒ Object
Returns the value of attribute log.
13
14
15
|
# File 'lib/cloudscale/monitor/preops/preop.rb', line 13
def log
@log
end
|
#registry ⇒ Object
Returns the value of attribute registry.
13
14
15
|
# File 'lib/cloudscale/monitor/preops/preop.rb', line 13
def registry
@registry
end
|
Instance Method Details
#init ⇒ Object
15
16
17
18
19
|
# File 'lib/cloudscale/monitor/preops/preop.rb', line 15
def init
@log = Logger.new(STDOUT)
@registry = Monitor::Registry.instance
@rest_client = RestClientWrapper.instance
end
|
#init_charts(path) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/cloudscale/monitor/preops/preop.rb', line 21
def init_charts(path)
log.info("Starting monitoring chart synchronization...")
agentInstanceId = @registry.agent_instance_id
plugin = YAML.load(JSON.parse(File.read(path)).to_yaml)
plugin.each do | key, chart |
chart["agentInstanceId"] = agentInstanceId
chart["queries"].each { | query |
query["command"].sub! '[[agentInstanceId]]', agentInstanceId
}
test_chart = @rest_client.searchOne("charts", "findByAgentInstanceIdAndChartId", { :agentInstanceId => agentInstanceId, :chartId => chart["chartId"]})
if (test_chart == nil)
@rest_client.post("charts", chart)
else
@rest_client.patch("charts", RestClientWrapper.load_entity_id(test_chart), chart)
end
end
log.info("Successfully synchronized charts...")
end
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/cloudscale/monitor/preops/preop.rb', line 45
def (path)
log.info("Starting monitoring menu synchronization...")
agentInstanceId = @registry.agent_instance_id
plugin = YAML.load(JSON.parse(File.read(path)).to_yaml)
plugin.each do | key, |
["agentInstanceId"] = agentInstanceId
= @rest_client.searchOne("menus", "findByAgentInstanceIdAndMenuId", { :agentInstanceId => agentInstanceId, :menuId => ["menuId"]})
if ( == nil)
@rest_client.post("menus", )
else
@rest_client.patch("menus", RestClientWrapper.load_entity_id(), )
end
end
log.info("Successfully synchronized menus...")
end
|