Class: Facts

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

Class Method Summary collapse

Class Method Details

.chart_data(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/app/models/facts.rb', line 11

def self.chart_data(options = {})
  facter_data = {}
  self.where(:timestamp.gte => options[:start]).
       where(:ip_address => options[:ip_address]).
where(:hostname => options[:hostname]).order_by(timestamp: :asc).each do |data|
    facter_data[data[:name]] ||= data[:value]
  end
  { :facter_data => facter_data }
end

.get_latest_facts_for_host(host_id) ⇒ Object



21
22
23
24
25
# File 'lib/app/models/facts.rb', line 21

def self.get_latest_facts_for_host(host_id)
  Facts.where(:host_id => host_id)
        where(:plugin_type => 'facts').
 last
end

.legendObject



27
28
29
# File 'lib/app/models/facts.rb', line 27

def self.legend
  @legend = {}
end