-
-
Save anonymous/cf705d5430447a5231c7 to your computer and use it in GitHub Desktop.
dashboard changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bgupta@metro:~/git/foreman$ git diff | |
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb | |
index ebd82e8..a721055 100644 | |
--- a/app/controllers/dashboard_controller.rb | |
+++ b/app/controllers/dashboard_controller.rb | |
@@ -15,18 +15,24 @@ class DashboardController < ApplicationController | |
def prefetch_data | |
@hosts = Host.search_for(params[:search]) | |
@report = { | |
- :total_hosts => @hosts.count, | |
- :bad_hosts => @hosts.recent.with_error.count, | |
- :active_hosts => @hosts.recent.with_changes.count, | |
- :active_hosts_ok => @hosts.recent.with_changes.without_error.count, | |
- :ok_hosts => @hosts.recent.successful.count, | |
- :out_of_sync_hosts => @hosts.out_of_sync.count, | |
- :disabled_hosts => @hosts.alerts_disabled.count, | |
- :pending_hosts => @hosts.recent.with_pending_changes.count, | |
+ :total_hosts => @hosts.count, | |
+ :bad_hosts => @hosts.recent.with_error.count, | |
+ :bad_hosts_enabled => @hosts.recent.with_error.alerts_enabled.count, | |
+ :active_hosts => @hosts.recent.with_changes.count, | |
+ :active_hosts_ok => @hosts.recent.with_changes.without_error.count, | |
+ :active_hosts_ok_enabled => @hosts.recent.with_changes.without_error.alerts_enabled.count, | |
+ :ok_hosts => @hosts.recent.successful.count, | |
+ :ok_hosts_enabled => @hosts.recent.successful.count, | |
+ :out_of_sync_hosts => @hosts.out_of_sync.count, | |
+ :out_of_sync_hosts_enabled => @hosts.out_of_sync.alerts_enabled.count, | |
+ :disabled_hosts => @hosts.alerts_disabled.count, | |
+ :pending_hosts => @hosts.recent.with_pending_changes.count, | |
+ :pending_hosts_enabled => @hosts.recent.with_pending_changes.alerts_enabled.count, | |
} | |
@report[:good_hosts] = @report[:ok_hosts] + @report[:active_hosts_ok] | |
+ @report[:good_hosts_enabled] = @report[:ok_hosts_enabled] + @report[:active_hosts_ok_enabled] | |
@report[:percentage] = (@report[:good_hosts] == 0 or @report[:total_hosts] == 0) ? 0 : @report[:good_hosts]*100 / @report[:total_hosts] | |
- @report[:reports_missing] = @report[:total_hosts] - @report[:good_hosts] - @report[:bad_hosts] - @report[:out_of_sync_hosts] - @report[:pending_hosts] | |
+ @report[:reports_missing] = @report[:total_hosts] - @report[:good_hosts_enabled] - @report[:bad_hosts_enabled] - @report[:out_of_sync_hosts_enabled] - @rep | |
end | |
end | |
diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb | |
index 994507d..c3daf2a 100644 | |
--- a/app/helpers/dashboard_helper.rb | |
+++ b/app/helpers/dashboard_helper.rb | |
@@ -15,11 +15,11 @@ module DashboardHelper | |
end | |
def render_overview report, options = {} | |
- data = [[:Active, report[:active_hosts]], | |
- [:Error, report[:bad_hosts]], | |
+ data = [[:Active, report[:active_hosts_ok_enabled]], | |
+ [:Error, report[:bad_hosts_enabled]], | |
[:OK, report[:ok_hosts]], | |
- [:'Pending changes', report[:pending_hosts]], | |
- [:'Out of sync', report[:out_of_sync_hosts]], | |
+ [:'Pending changes', report[:pending_hosts_enabled]], | |
+ [:'Out of sync', report[:out_of_sync_hosts_enabled]], | |
[:'No report', report[:reports_missing]], | |
[:'Notification disabled', report[:disabled_hosts]]] | |
pie_chart 'overview', 'Puppet Clients Activity Overview', data, options | |
diff --git a/app/models/host.rb b/app/models/host.rb | |
index 3d2520a..ae7dbc6 100644 | |
--- a/app/models/host.rb | |
+++ b/app/models/host.rb | |
@@ -75,6 +75,8 @@ class Host < Puppet::Rails::Host | |
scope :alerts_disabled, {:conditions => ["enabled = ?", false] } | |
+ scope :alerts_enabled, {:conditions => ["enabled = ?", true] } | |
+ | |
scope :my_hosts, lambda { | |
user = User.current | |
owner_conditions = sanitize_sql_for_conditions(["((hosts.owner_id in (?) AND hosts.owner_type = 'Usergroup') OR (hosts.owner_id = ? AND hosts.owner_typ | |
diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb | |
index 52aebcd..86da96c 100644 | |
--- a/app/views/dashboard/index.html.erb | |
+++ b/app/views/dashboard/index.html.erb | |
@@ -7,27 +7,27 @@ | |
<th>Data</th> | |
</tr> | |
<tr> | |
- <td><%= searchable_links 'Hosts that had performed modifications', "last_report > \"#{Setting[:puppet_interval] + 5} minutes ago\" and (status.applied > | |
- <td><%= @report[:active_hosts] %> </td> | |
+ <td><%= searchable_links 'Hosts that had performed modifications without error', "last_report > \"#{Setting[:puppet_interval] + 5} minutes ago\" and (sta | |
+ <td><%= @report[:active_hosts_ok_enabled] %> </td> | |
</tr> | |
<tr> | |
- <td><%= searchable_links 'Hosts in Error State', "last_report > \"#{Setting[:puppet_interval] + 5} minutes ago\" and (status.failed > 0 or status.failed_ | |
- <td><%= @report[:bad_hosts] %> </td> | |
+ <td><%= searchable_links 'Hosts in Error State', "last_report > \"#{Setting[:puppet_interval] + 5} minutes ago\" and (status.failed > 0 or status.failed_ | |
+ <td><%= @report[:bad_hosts_enabled] %> </td> | |
</tr> | |
<tr> | |
- <td><%=searchable_links "Good Host Reports in the last #{Setting[:puppet_interval]+5} minutes", "last_report > \"#{Setting[:puppet_interval]+5} minutes a | |
- <td> <%= "#{@report[:good_hosts]} / #{@report[:total_hosts]}" %> hosts (<%= @report[:percentage] %>%)</td> | |
+ <td><%=searchable_links "Good Host Reports in the last #{Setting[:puppet_interval]+5} minutes", "last_report > \"#{Setting[:puppet_interval]+5} minutes a | |
+ <td> <%= "#{@report[:good_hosts_enabled] - @report[:active_hosts_ok_enabled]} / #{@report[:total_hosts]}" %> hosts (<%= @report[:percentage] %>%)</td> | |
</tr> | |
<tr> | |
- <td><%= searchable_links 'Hosts that had pending changes', 'status.pending > 0' %></td> | |
- <td><%= @report[:pending_hosts] %> </td> | |
+ <td><%= searchable_links 'Hosts that had pending changes', 'status.pending > 0 and status.enabled = true' %></td> | |
+ <td><%= @report[:pending_hosts_enabled] %> </td> | |
</tr> | |
<tr> | |
<td><%= searchable_links 'Out Of Sync Hosts', "last_report < \"#{Setting[:puppet_interval] + 5} minutes ago\" and status.enabled = true" %></td> | |
- <td><%= @report[:out_of_sync_hosts] %> </td> | |
+ <td><%= @report[:out_of_sync_hosts_enabled] %> </td> | |
</tr> | |
<tr> | |
- <td><%= searchable_links 'Hosts With No Reports', "not has last_report" %></td> | |
+ <td><%= searchable_links 'Hosts With No Reports', "not has last_report and status.enabled = true" %></td> | |
<td><%= @report[:reports_missing] %> </td> | |
</tr> | |
<tr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment