Class: Fpm
- Inherits:
-
Object
- Object
- Fpm
- Includes:
- Mongoid::Attributes::Dynamic, Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/app/models/fpm.rb
Class Method Summary collapse
- .axes ⇒ Object
- .chart_data(options = {}) ⇒ Object
- .fpm_chart(pool, values) ⇒ Object
- .fpms_charts(options = {}) ⇒ Object
- .graphs ⇒ Object
Class Method Details
.axes ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/app/models/fpm.rb', line 115 def self.axes [ { :name => 'valueAxis1', :title => 'Accepted connections per second', :position => 'right', :min_max_multiplier => 1, :grid_alpha => 0.07, :include_guides_in_min_max => 'true', :stack_type => "none" }, { :name => 'valueAxis2', :title => 'Active processes', :position => 'left', :grid_alpha => 0.07, :min_max_multiplier => 1, :include_guides_in_min_max => 'true', :stack_type => "regular" } ] end |
.chart_data(options = {}) ⇒ Object
8 9 10 11 |
# File 'lib/app/models/fpm.rb', line 8 def self.chart_data( = {}) charts = self.fpms_charts() return charts end |
.fpm_chart(pool, values) ⇒ Object
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/fpm.rb', line 25 def self.fpm_chart(pool, values) max_active_processes = 0 chart_data = { :value_axes => self.axes, :graph_data => [], :graphs => self.graphs, :title => "#{pool} FPM pool statistic", :category_field => 'timestamp', :title_size => 20, :guides => {} } prev = nil values.each do |value| temp = {} if prev.nil? then prev = value next end time_diff = value[:timestamp].to_i - prev[:timestamp].to_i accepted_connections_per_sec = ((value[:accepted_connections] - prev[:accepted_connections])/time_diff.to_f).round(3) #Interpolation of no data intervals if accepted_connections_per_sec < 0 prev = value next end max_active_processes = value[:processes_active_max] if value[:processes_active_max] > max_active_processes temp = {'timestamp' => value[:timestamp]} temp[:processes_active] = value[:processes_active] temp[:processes_idle] = value[:processes_idle] temp[:accepted_connections_per_sec] = accepted_connections_per_sec.to_f prev = value chart_data[:graph_data] << temp end chart_data[:guides] = [ { :value => max_active_processes, :value_axis => 'valueAxis2', :line_color => "#FF0000", :line_thickness => 1, :dash_length => 5, :label => "Max processes", :inside => 'true', :line_alpha => 1, :position => 'bottom', } ] return chart_data end |
.fpms_charts(options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/app/models/fpm.rb', line 13 def self.fpms_charts( = {}) charts = [] Fpm.where(:timestamp.gte => [:start]). where(:timestamp.lt => [:end]). where(:host_id => [:host_id]). where(:plugin_id => [:plugin_id]). order_by(timestamp: :asc).group_by{|u| u.pool}.each_pair do |pool, values| charts << self.fpm_chart(pool,values) end return charts end |
.graphs ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/app/models/fpm.rb', line 80 def self.graphs [ { :value_field => "processes_active", :graph_type => 'line', :hidden => false, :balloon_text => "[[title]]: ([[value]])", :line_color => "#FF0000", :line_thickness => 1, :line_alpha => 1, :fill_alphas => 0.6, :title => "Active Processes", :value_axis => "valueAxis2"}, { :value_field => "processes_idle", :graph_type => 'line', :hidden => false, :balloon_text => "[[title]]: ([[value]])", :line_color => "#00FF00", :line_thickness => 1, :line_alpha => 1, :fill_alphas => 0.6, :title => "Idle processes", :value_axis => "valueAxis2"}, { :value_field => "accepted_connections_per_sec", :graph_type => 'line', :hidden => false, :balloon_text => "[[title]]: ([[value]])", :line_color => "#0000FF", :line_thickness => 3, :line_alpha => 1, :fill_alphas => 0, :title => "Accepted connections per second", :value_axis => "valueAxis1"}, ] end |