Bug #1170
Statistics Page - Group by Hostgroups
| Status: | Assigned | Start: | 09/14/2011 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assigned to: | % Done: | 0% |
||
| Category: | Web Interface | |||
| Target version: | - | |||
| Backlog: | No | Difficulity: | ||
| Votes: | 0 |
Description
Seems as though you have 9 pie charts and 10 would give balance...
# diff -u statistics_controller.rb statistics_controller.rb-new
--- statistics_controller.rb 2011-09-14 09:47:57.712461508 -0700
+++ statistics_controller.rb-new 2011-09-14 09:47:34.372454180 -0700
@@ -5,6 +5,7 @@
@arch_count = Host.count_distribution :architecture
@env_count = Host.count_distribution :environment
@klass_count = Host.count_habtm "puppetclass"
+ @group_count = Host.gr_totals
@cpu_count = FactValue.count_each "processorcount"
@model_count = FactValue.count_each "manufacturer"
@mem_size = FactValue.mem_average "memorysize"
@@ -16,7 +17,7 @@
respond_to do |format|
format.html
format.json do
- render :json => { :statistics => { :os_count => @os_count, :arch_count => @arch_count,
+ render :json => { :statistics => { :os_count => @os_count, :arch_count => @arch_count, :host_groups => @group_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 } }
# diff -u host.rb host.rb-new
--- host.rb 2011-09-14 09:52:07.932460435 -0700
+++ host.rb-new 2011-09-14 09:51:46.032454329 -0700
@@ -626,4 +626,14 @@
status
end
+ def self.gr_totals
+ @grouphash = {}
+ @hostgroups = Hostgroup.find(:all)
+ @hostgroups.each do |group|
+ @groupname = group.name
+ @group_count = Host.count(:all, :conditions => ["hostgroup_id = ?", group.id])
+ @grouphash[@groupname] = @group_count
+ end
+ return @grouphash
+ end
end
# diff -u index.html.erb index.html.erb-new
--- index.html.erb 2011-09-14 09:53:39.262459112 -0700
+++ index.html.erb-new 2011-09-14 09:53:27.452460645 -0700
@@ -17,4 +17,6 @@
<%= pie_chart("mem_totals" ,"Total memory usage", [["free memory (GB)", @mem_totfree],["used memory (GB)",@mem_totsize-@mem_totfree]]) %>
+ <%= pie_chart("host_groups" ,"Host Group Distribution", @group_count) %>
+
</center>
History
Updated by Ohad Levy over 1 year ago
- Assigned to set to Craig White
while in the latest view the stats are aligned, it would still be nice to have this patch, mind sending it via git as well ? :)
Updated by Benjamin Papillon 6 months ago
- Category set to Web Interface
- Status changed from New to Assigned
- Assigned to changed from Craig White to Amos Benari
