Class: Webobjects

Inherits:
Object
  • Object
show all
Includes:
Graphs::AreaStackedChart, Mongoid::Attributes::Dynamic, Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/app/models/webobjects.rb

Class Method Summary collapse

Class Method Details

.all_applications_charts(options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/app/models/webobjects.rb', line 26

def self.all_applications_charts(options = {})
  charts = []
  Webobjects.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).group_by{|u| u.name}.each_pair do |app, stats|
    charts << self.application_charts(app,stats)
  end
  return charts.flatten
end

.all_sensors_applications_charts(options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/app/models/webobjects.rb', line 15

def self.all_sensors_applications_charts(options = {})
  charts = []
  Webobjects.where(:timestamp.gte => options[:start]).
             where(:timestamp.lt => options[:end]).
      where(:plugin_type => 'webobjects').
      order_by(timestamp: :asc).group_by{|u| u.name}.each_pair do |app, stats|
    charts << self.application_charts(app,stats)
  end
  return charts.flatten
end

.application_charts(app, app_stats) ⇒ Object



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
# File 'lib/app/models/webobjects.rb', line 38

def self.application_charts(app,app_stats)
  chart = self.chart_structure({:title => "Number of sessions - #{app} application", :value_axis => { :title => "Number of sessions"}})
  prev = nil
  instances = Hash.new
  app_stats.group_by {|s| s.timestamp}.each do |timestamp, stats|
    temp = {:timestamp => timestamp}
    stats.each do |stat|
    #<Webobjects _id: 201, created_at: nil, updated_at: nil, name: "ifirma", host: "ifirmaapp01", port: "2201", state: "ALIVE", deaths: "0", refusingNewSessions: false, scheduled: false, schedulingHourlyStartTime: 3, schedulingDailyStartTime: 3, schedulingWeeklyStartTime: 3, schedulingType: "DAILY", schedulingStartDay: 1, schedulingInterval: 12, transactions: "284487", activeSessions: "41", averageIdlePeriod: "0.646", avgTransactionTime: "0.054", autoRecover: "true", timestamp: 2018-10-17 06:16:31 UTC, host_id: BSON::ObjectId('5bc6d3bf7327d40cb44d9ad6'), plugin_id: BSON::ObjectId('5bc6d3c07327d40cb44d9af7'), plugin_type: "webobjects"
      instances[stat[:instance_id]] ||= true
      temp[stat[:instance_id]] = stat[:activeSessions].to_i
    end
    chart[:graph_data] << temp 
  end
  instances.keys.each do |graph|
    chart[:graphs] << { :value_axis => 'valueAxis1', :value_field => graph, :balloon_text => "[[title]]: ([[value]])", :line_thickness => 1, :line_alpha => 1, :fill_alphas => 0.1, :graph_type => 'line' }
  end

#    tps = self.tps_graph(app)
#    instances.keys.each do |graph|
#      tps[:graphs] << { :value_axis => 'valueAxis1', :value_field => graph.to_s,  :balloon_text => "[[title]]: ([[value]])", :line_thickness => 1, :line_alpha => 1, :fill_alphas => 0.1, :graph_type => 'line' }
#    end
  
#    sessions = sessions_graph(app)
#    instances.keys.each do |graph|
#      sessions[:graphs] << { :value_axis => 'valueAxis1', :value_field => graph, :balloon_text => "[[title]]: ([[value]])", :line_thickness => 1, :line_alpha => 1, :fill_alphas => 0.1, :graph_type => 'line' }
#    end
#    sessions[:graph_data] = chart_data[:sessions]
#    tps[:graph_data] = chart_data[:tps]
#    chart[:graph_data] = chart_data[:sessions]
  p chart
  return chart
end

.chart_data(options = {}) ⇒ Object



9
10
11
12
13
# File 'lib/app/models/webobjects.rb', line 9

def self.chart_data(options = {})
  charts = []
  charts = self.all_applications_charts(options)
  return charts
end

.graphsObject



75
76
77
78
79
# File 'lib/app/models/webobjects.rb', line 75

def self.graphs
  {
    :sessions => { :line_color => '#0033FF' },
  }
end

.sessions_graph(app) ⇒ Object



80
81
82
# File 'lib/app/models/webobjects.rb', line 80

def self.sessions_graph(app)
  return self.chart_structure({:title => "Number of sessions - #{app} application", :value_axis => { :title => "Number of sessions"}})
end

.tps_graph(app) ⇒ Object



71
72
73
# File 'lib/app/models/webobjects.rb', line 71

def self.tps_graph(app)
  return self.chart_structure({:title => "Transactions per second - #{app} application", :value_axis => { :title => "Transactions/sec"}})
end