Bug #138

Statistics page doesn't show any info if memory facts are unavailable

Added by Nigel Kersten about 8 years ago. Updated about 8 years ago.

Status:Closed
Priority:Normal
Assigned To:Nigel Kersten
Category:Inventory
Target version:0.1-4
Difficulty: Bugzilla link:
Found in release: Pull request:
Story points-
Velocity based estimate-

Description

On my recent git install of foreman, when I go to http://myforeman:3000/statistics

"No Inventory data has been found - add some hosts and facts and try again"

However I have lots of hosts with inventory data.

Associated revisions

Revision 52a909a3
Added by Ohad Levy about 8 years ago

fixes #138 - Statistics page doesn't show any info if memory facts are unavailable

History

#1 Updated by Ohad Levy about 8 years ago

I would your help to debug this a bit, could you try opening a console - e.g.

./script/console production

and copy paste every line from the index method of the statistics controller (app/controllers/statistics_controller)?
one one of them will give a useful error message.

thanks

#2 Updated by Ohad Levy about 8 years ago

  • Category set to Inventory
  • Status changed from New to Need more information
  • Assigned To set to Nigel Kersten

#3 Updated by John Lyman about 8 years ago

I am also having the same issue. Here is the output from my console session:

./script/console production
Loading production environment (Rails 2.3.2)

class StatisticsController < ApplicationController
def index
begin

?> @os_count = Host.count_distribution :operatingsystem

@arch_count = Host.count_distribution :architecture
@env_count = Host.count_distribution :environment
@klass_count = Host.count_habtm "puppetclass"
@cpu_count = FactValue.count_each "processorcount"
@model_count = FactValue.count_each "manufacturer"
@mem_size = FactValue.mem_average "memorysize"
@mem_free = FactValue.mem_average "memoryfree"
@swap_size = FactValue.mem_average "swapsize"
@swap_free = FactValue.mem_average "swapfree"
rescue
render :text => "No Inventory data has been found - add some hosts and facts and try again", :layout => true
end
end
end

=> nil

Also, under the "Settings" tab, "Puppet Classes" and "Puppet Groups" have no entries. "Domains", "Operating Systems", "Architectures", etc. are populated. Not sure if this is related to the issue or not.

#4 Updated by John Lyman about 8 years ago

Sorry, I should have previewed that before I submitted. Here is the console output in a better format:

./script/console production
Loading production environment (Rails 2.3.2)
>> class StatisticsController < ApplicationController
>>   def index
>>     begin
?>       @os_count = Host.count_distribution :operatingsystem
>>       @arch_count = Host.count_distribution :architecture
>>       @env_count = Host.count_distribution :environment
>>       @klass_count = Host.count_habtm "puppetclass" 
>>       @cpu_count = FactValue.count_each "processorcount" 
>>       @model_count = FactValue.count_each "manufacturer" 
>>       @mem_size = FactValue.mem_average "memorysize" 
>>       @mem_free = FactValue.mem_average "memoryfree" 
>>       @swap_size = FactValue.mem_average "swapsize" 
>>       @swap_free = FactValue.mem_average "swapfree" 
>>     rescue
>>       render :text => "No Inventory data has been found - add some hosts and facts and try again", :layout => true
>>     end
>>   end
>> end
=> nil

#5 Updated by John Warburton about 8 years ago

I get this error when I have a new host entry sent by the puppet report (foreman.rb) but before the facts are delivered to the central foreman server via push_facts.rb.

So, a single new host with no facts blows the statistics page away until the facts appear

Since push_facts runs every 5 minutes and the number of new hosts added is low, it is a rare error message for me, so I didn't worry about reporting it

http://theforeman.org/wiki/foreman/Puppet_Facts

#6 Updated by John Lyman about 8 years ago

I have a cron that runs

rake puppet:import:hosts_and_facts RAILS_ENV=production
every 5 minutes without errors, and I still don't see the statistics page.

#7 Updated by Ohad Levy about 8 years ago

John Lyman wrote:

Sorry, I should have previewed that before I submitted. Here is the console output in a better format:
[...]

You should execute everything between the begin and rescue, if you include those (begin rescue end), you will not see the actual error message...

once I'm back from my vacation, I'll add some error handling into the logs, so it would be obvious where the error is..

#8 Updated by John Lyman about 8 years ago

Here it is again, with just the statements between begin and rescue. It looks like some facts have null values, but I'm not sure how to debug further...

Loading production environment (Rails 3.3.2)
>> @os_count = Host.count_distribution :operatingsystem
=> {"Solaris 5.10"=>8}
>> @arch_count = Host.count_distribution :architecture
=> {"i386"=>4, "sparc"=>4}
>> @env_count = Host.count_distribution :environment
=> {"production"=>8}
>> @klass_count = Host.count_habtm "puppetclass" 
=> {nil=>8}
>> @cpu_count = FactValue.count_each "processorcount" 
=> {}
>> @model_count = FactValue.count_each "manufacturer" 
=> {"Sun microsystems"=>4}
>> @mem_size = FactValue.mem_average "memorysize" 
ZeroDivisionError: divided by 0
        from /export/home/jlyman/foreman/foreman/app/models/fact_value.rb:14:in `/'
        from /export/home/jlyman/foreman/foreman/app/models/fact_value.rb:14:in `mem_average'
        from (irb):7
>> @mem_free = FactValue.mem_average "memoryfree" 
ZeroDivisionError: divided by 0
        from /export/home/jlyman/foreman/foreman/app/models/fact_value.rb:14:in `/'
        from /export/home/jlyman/foreman/foreman/app/models/fact_value.rb:14:in `mem_average'
        from (irb):8
>> @swap_size = FactValue.mem_average "swapsize" 
ZeroDivisionError: divided by 0
        from /export/home/jlyman/foreman/foreman/app/models/fact_value.rb:14:in `/'
        from /export/home/jlyman/foreman/foreman/app/models/fact_value.rb:14:in `mem_average'
        from (irb):9
>> @swap_free = FactValue.mem_average "swapfree" 
ZeroDivisionError: divided by 0
        from /export/home/jlyman/foreman/foreman/app/models/fact_value.rb:14:in `/'
        from /export/home/jlyman/foreman/foreman/app/models/fact_value.rb:14:in `mem_average'
        from (irb):10

#9 Updated by John Lyman about 8 years ago

Apparently, there are no memory facts for puppet on Solaris:

Feature #1423 - Memory facts for Solaris

#10 Updated by Ohad Levy about 8 years ago

John Lyman wrote:

Here it is again, with just the statements between begin and rescue. It looks like some facts have null values, but I'm not sure how to debug further...
[...]

OK - this is a stupid yet simple bug to fix, to get around the problem for now, just comment out the two methods (memory and swap queries) - I'll get to it when I'm back.

(you would also need to comment it out in the view (I think app/views/statistics/index.html.erb) - where it says something like Avg memory usage

#11 Updated by John Lyman about 8 years ago

It's working now, thanks.

#12 Updated by Nigel Kersten about 8 years ago

I imagine I have the same problem due to Mac clients not reporting the memory facts too? Back from holidays today, will investigate more.

#13 Updated by Ohad Levy about 8 years ago

  • Status changed from Need more information to Assigned
  • Target version set to 0.1-4

#14 Updated by Ohad Levy about 8 years ago

  • Subject changed from Statistics page doesn't show any info. to Statistics page doesn't show any info if memory facts are unavailable

#15 Updated by Ohad Levy about 8 years ago

  • Status changed from Assigned to Ready For Testing
  • % Done changed from 0 to 100

#16 Updated by Ohad Levy about 8 years ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF