16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/app/models/load.rb', line 16
def self.load_chart(options)
chart = self.chart_structure({:title => "Host load average", :value_axis => { :title => "Load averages"}, :include_guides_in_min_max => false})
graphs = [ :load_1m, :load_5m, :load_15m ]
chart[:graph_data] = Load.where(:timestamp.gte => options[:start]).
where(:timestamp.lt => options[:end]).
where(:host_id => options[:host_id]).
where(:plugin_id => options[:plugin_id]).
order_by(timestamp: :asc)
host_facts = Facts.get_latest_facts_for_host(options[:host_id])
unless host_facts.nil?
cores_total = host_facts['facts']['processors']['count']
guides = [ {
:value => 0,
:to_value => cores_total,
:value_axis => 'valueAxis1',
:line_color => "#00FF00",
:fill_color => "#00FF00",
:line_thickness => 1,
:dash_length => 5,
:label => "",
:inside => false,
:line_alpha => 1,
:fill_alpha => 0.1,
:position => 'bottom'},
{:value => cores_total,
:to_value => cores_total * 2,
:value_axis => 'valueAxis1',
:line_color => "#FFFF00",
:fill_color => "#FFFF00",
:line_thickness => 1,
:dash_length => 5,
:label => "",
:inside => false,
:line_alpha => 1,
:fill_alpha => 0.1,
:position => 'bottom'},
{:value => cores_total * 2,
:to_value => cores_total * 10,
:value_axis => 'valueAxis1',
:line_color => "#FF0000",
:fill_color => "#FF0000",
:line_thickness => 1,
:dash_length => 5,
:label => "",
:inside => false,
:line_alpha => 1,
:fill_alpha => 0.1,
:position => 'bottom'}]
end
chart[:guides] = guides
chart
end
|