Bug #138
closedStatistics page doesn't show any info if memory facts are unavailable
Added by Nigel Kersten about 15 years ago. Updated almost 15 years ago.
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.
Updated by Ohad Levy about 15 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
Updated by Ohad Levy about 15 years ago
- Category set to Inventory
- Status changed from New to Need more information
- Assignee set to Nigel Kersten
Updated by John Lyman about 15 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.
Updated by John Lyman about 15 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
Updated by John Warburton about 15 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
Updated by John Lyman about 15 years ago
I have a cron that runs
rake puppet:import:hosts_and_facts RAILS_ENV=productionevery 5 minutes without errors, and I still don't see the statistics page.
Updated by Ohad Levy about 15 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..
Updated by John Lyman almost 15 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
Updated by John Lyman almost 15 years ago
Apparently, there are no memory facts for puppet on Solaris:
Updated by Ohad Levy almost 15 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
Updated by Nigel Kersten almost 15 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.
Updated by Ohad Levy almost 15 years ago
- Status changed from Need more information to Assigned
- Target version set to 0.1-4
Updated by Ohad Levy almost 15 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
Updated by Ohad Levy almost 15 years ago
- Status changed from Assigned to Ready For Testing
- % Done changed from 0 to 100
Applied in changeset 52a909a39b9766e2a579f1819fcd090d1a123346.
Updated by Ohad Levy almost 15 years ago
- Status changed from Ready For Testing to Closed