[PATCH/foreman 1/1] Fix dashboard pie, to contain correct total number of hosts

to me this makes sense. Don't shoot me if the logic isn't 100% correct…

in short, active hosts are counted as ok hosts, which makes the
counters get higher than the number of total hosts sometimes.
To bring the pie to the sum of the hosts, only the missing reports
should be added, which is included too.

Tim

Signed-off-by: Tim Speetjens <tim.speetjens@gmail.com>

··· --- app/controllers/dashboard_controller.rb | 2 ++ app/helpers/dashboard_helper.rb | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/app/controllers/dashboard_controller.rb
b/app/controllers/dashboard_controller.rb
index ea8f10f…7e915b4 100644
— a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -23,6 +23,8 @@ class DashboardController < ApplicationController
:disabled_hosts => hosts.alerts_disabled.count
}
@report[:percentage] = (@report[:good_hosts] == 0 or
@report[:total_hosts] == 0) ? 0 : @report[:good_hosts]*100 /
@report[:total_hosts]

  • @report[:ok_hosts] = @report[:good_hosts] - @report[:active_hosts]
  • @report[:reports_missing] = @report[:total_hosts] -
    @report[:good_hosts] - @report[:bad_hosts] -
    @report[:out_of_sync_hosts]
    end

end
diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb
index af3e205…ed0d3e6 100644
— a/app/helpers/dashboard_helper.rb
+++ b/app/helpers/dashboard_helper.rb
@@ -60,8 +60,9 @@ module DashboardHelper
data: [
[‘Active’, #{report[:active_hosts]}],
[‘Error’, #{report[:bad_hosts]}],

  •        ['OK',       #{report[:good_hosts]}],
    
  •        ['Out of sync',   #{report[:out_of_sync_hosts]}]
    
  •        ['OK',       #{report[:ok_hosts]}],
    
  •        ['Out of sync',   #{report[:out_of_sync_hosts]}],
    
  •        ['No report', #{report[:reports_missing]}]
        ]
     }]
    
    });

    1.7.2.5

whats the diff between out of sync and no reports?

Thanks
Ohad

··· On Tue, Oct 25, 2011 at 9:35 PM, Tim Speetjens wrote: > to me this makes sense. Don't shoot me if the logic isn't 100% correct... > > in short, active hosts are counted as ok hosts, which makes the > counters get higher than the number of total hosts sometimes. > To bring the pie to the sum of the hosts, only the missing reports > should be added, which is included too. > > Tim > > Signed-off-by: Tim Speetjens > --- > app/controllers/dashboard_controller.rb | 2 ++ > app/helpers/dashboard_helper.rb | 5 +++-- > 2 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/app/controllers/dashboard_controller.rb > b/app/controllers/dashboard_controller.rb > index ea8f10f..7e915b4 100644 > --- a/app/controllers/dashboard_controller.rb > +++ b/app/controllers/dashboard_controller.rb > @@ -23,6 +23,8 @@ class DashboardController < ApplicationController > :disabled_hosts => hosts.alerts_disabled.count > } > @report[:percentage] = (@report[:good_hosts] == 0 or > @report[:total_hosts] == 0) ? 0 : @report[:good_hosts]*100 / > @report[:total_hosts] > + @report[:ok_hosts] = @report[:good_hosts] - @report[:active_hosts] > + @report[:reports_missing] = @report[:total_hosts] - > @report[:good_hosts] - @report[:bad_hosts] - > @report[:out_of_sync_hosts] > end > > end > diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb > index af3e205..ed0d3e6 100644 > --- a/app/helpers/dashboard_helper.rb > +++ b/app/helpers/dashboard_helper.rb > @@ -60,8 +60,9 @@ module DashboardHelper > data: [ > ['Active', #{report[:active_hosts]}], > ['Error', #{report[:bad_hosts]}], > - ['OK', #{report[:good_hosts]}], > - ['Out of sync', #{report[:out_of_sync_hosts]}] > + ['OK', #{report[:ok_hosts]}], > + ['Out of sync', #{report[:out_of_sync_hosts]}], > + ['No report', #{report[:reports_missing]}] > ] > }] > }); > -- > 1.7.2.5 >

The hosts that haven't reported at all, or technically where
last_reported is null would be.

I agree that in many cases this would become UI bloat. Maybe just show
it when it's applicable?

Tim

··· Op 26 oktober 2011 16:00 heeft Ohad Levy het volgende geschreven: > On Tue, Oct 25, 2011 at 9:35 PM, Tim Speetjens wrote: >> to me this makes sense. Don't shoot me if the logic isn't 100% correct... >> >> in short, active hosts are counted as ok hosts, which makes the >> counters get higher than the number of total hosts sometimes. >> To bring the pie to the sum of the hosts, only the missing reports >> should be added, which is included too. >> >> Tim >> >> Signed-off-by: Tim Speetjens >> --- >> app/controllers/dashboard_controller.rb | 2 ++ >> app/helpers/dashboard_helper.rb | 5 +++-- >> 2 files changed, 5 insertions(+), 2 deletions(-) >> >> diff --git a/app/controllers/dashboard_controller.rb >> b/app/controllers/dashboard_controller.rb >> index ea8f10f..7e915b4 100644 >> --- a/app/controllers/dashboard_controller.rb >> +++ b/app/controllers/dashboard_controller.rb >> @@ -23,6 +23,8 @@ class DashboardController < ApplicationController >> :disabled_hosts => hosts.alerts_disabled.count >> } >> @report[:percentage] = (@report[:good_hosts] == 0 or >> @report[:total_hosts] == 0) ? 0 : @report[:good_hosts]*100 / >> @report[:total_hosts] >> + @report[:ok_hosts] = @report[:good_hosts] - @report[:active_hosts] >> + @report[:reports_missing] = @report[:total_hosts] - >> @report[:good_hosts] - @report[:bad_hosts] - >> @report[:out_of_sync_hosts] >> end >> >> end >> diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb >> index af3e205..ed0d3e6 100644 >> --- a/app/helpers/dashboard_helper.rb >> +++ b/app/helpers/dashboard_helper.rb >> @@ -60,8 +60,9 @@ module DashboardHelper >> data: [ >> ['Active', #{report[:active_hosts]}], >> ['Error', #{report[:bad_hosts]}], >> - ['OK', #{report[:good_hosts]}], >> - ['Out of sync', #{report[:out_of_sync_hosts]}] >> + ['OK', #{report[:ok_hosts]}], >> + ['Out of sync', #{report[:out_of_sync_hosts]}], >> + ['No report', #{report[:reports_missing]}] >> ] >> }] >> }); >> -- >> 1.7.2.5 >> > > whats the diff between out of sync and no reports? > > Thanks > Ohad >

I found out yesterday that the patch only corrects the values in the
pie. The real cause of the problem seems to be an invalid search
scope.
I have a patch ready, when I'm done testing, I'll submit it.

Tim

> I found out yesterday that the patch only corrects the values in the
> pie. The real cause of the problem seems to be an invalid search
> scope.
> I have a patch ready, when I'm done testing, I'll submit it.
thanks, I've already commited this one, so please make a new one.

ohad

··· On Fri, Oct 28, 2011 at 8:28 AM, Tim Speetjens wrote: > > Tim >

>> I found out yesterday that the patch only corrects the values in the
>> pie. The real cause of the problem seems to be an invalid search
>> scope.
>> I have a patch ready, when I'm done testing, I'll submit it.
> thanks, I've already commited this one, so please make a new one.

I noticed. I'll take the latest git code to start from.

Tim

··· Op 28 oktober 2011 08:58 heeft Ohad Levy het volgende geschreven: > On Fri, Oct 28, 2011 at 8:28 AM, Tim Speetjens wrote:

ohad

Tim