Class: Disk

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

Class Method Summary collapse

Class Method Details

.all_disks_charts(options) ⇒ Object



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

def self.all_disks_charts(options)
  charts = []
  Disk.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.mount}.each_pair do |mount, values|
    charts << self.disk_chart(mount, values)
  end
  return charts
end

.chart_data(options = {}) ⇒ Object



10
11
12
13
14
# File 'lib/app/models/disk.rb', line 10

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

.disk_chart(mount, values) ⇒ Object



28
29
30
31
32
33
# File 'lib/app/models/disk.rb', line 28

def self.disk_chart(mount, values)
  chart = self.chart_structure({:title => "Disk space usage for #{mount}", :value_axis => { :title => "Disk usage in KB"}})
  #TODO - get fields from above DRY
  chart[:graph_data] = values
  chart
end

.graphsObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/app/models/disk.rb', line 35

def self.graphs
  {
    :block_used => {
      :hidden => false,
      :line_color => "#FF0000",
      :line_thickness => 3,
      :title => "block used"
    },
    :block_free => { 
       :hidden => false,
       :line_color => "#00FF00",
       :line_thickness => 3,
       :title => "block free"
    }
  }
end