Class: StatisticsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/statistics_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#api_request?, #welcome

Methods included from Foreman::ThreadSession::Cleaner

#clear_thread, included

Instance Method Details

#indexObject


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/statistics_controller.rb', line 3

def index
  @os_count    = Host.my_hosts.count_distribution :operatingsystem
  @arch_count  = Host.my_hosts.count_distribution :architecture
  @env_count   = Host.my_hosts.count_distribution :environment
  @klass_count = Host.my_hosts.count_habtm "puppetclass"
  @cpu_count   = FactValue.my_facts.count_each "processorcount"
  @model_count = FactValue.my_facts.count_each "manufacturer"
  @mem_size    = FactValue.my_facts.mem_average "memorysize"
  @mem_free    = FactValue.my_facts.mem_average "memoryfree"
  @swap_size   = FactValue.my_facts.mem_average "swapsize"
  @swap_free   = FactValue.my_facts.mem_average "swapfree"
  @mem_totsize = FactValue.my_facts.mem_sum "memorysize"
  @mem_totfree = FactValue.my_facts.mem_sum "memoryfree"
  respond_to do |format|
    format.html
    format.json do
      render :json => { :statistics => { :os_count    => @os_count, :arch_count => @arch_count,
                                         :env_count   => @env_count, :klass_count => @klass_count, :cpu_count => @cpu_count,
                                         :model_count => @model_count, :mem_size => @mem_size, :mem_free => @mem_free, :swap_size => @swap_size,
                                         :swap_free   => @swap_free, :mem_totsize => @mem_totsize, :mem_totfree => @mem_totfree } }
    end
  end
end