From: Michael Tremer Date: Sat, 22 Jan 2011 12:01:35 +0000 (+0100) Subject: fireinfo: Display core count table and accumulated bogomips. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=62c3fa484408526bf869a8a3d3b4de304742a125;p=ipfire.org.git fireinfo: Display core count table and accumulated bogomips. --- diff --git a/www/templates/stasy-stats-cpus.html b/www/templates/stasy-stats-cpus.html index 84742313..e34fff2a 100644 --- a/www/templates/stasy-stats-cpus.html +++ b/www/templates/stasy-stats-cpus.html @@ -19,9 +19,17 @@

{{ _("Speed") }}

{{ _("The average speed of all systems in the database is: %.2f MHz.") % average_speed }} +
+ {{ _("All together, there are %s bogomips out there.") % locale.friendly_number(bogomips) }}

{{ modules.StasyTable(cpu_speeds) }} +

{{ _("CPU cores counter") }}

+

+ {{ _("See a breakdown of the CPU cores that are installed on the IPFire systems.") }} +

+ {{ modules.StasyCPUCoreTable(cpu_cores) }} + diff --git a/www/translations/de_DE.csv b/www/translations/de_DE.csv index cbaa0d34..89f1133b 100644 --- a/www/translations/de_DE.csv +++ b/www/translations/de_DE.csv @@ -260,3 +260,6 @@ "Worldwide mirror servers","Weltweite Mirror-Server" "Preferred for","Bevorzugt für" "Profile not found","Profil nicht gefunden" +"See a breakdown of the CPU cores that are installed on the IPFire systems.","Hier ist eine Übersicht über die Anzahl der CPU-Kerne, die in den IPFire-Systemen installiert sind." +"CPU cores counter","CPU-Kerne" +"All together, there are %s bogomips out there.","Insgesamt bringen es alle Systeme auf %s bogomips." diff --git a/www/webapp/__init__.py b/www/webapp/__init__.py index 9dbb16fd..9574a646 100644 --- a/www/webapp/__init__.py +++ b/www/webapp/__init__.py @@ -37,6 +37,7 @@ class Application(tornado.web.Application): "SidebarBanner" : SidebarBannerModule, "SidebarRelease" : SidebarReleaseModule, "StasyTable" : StasyTableModule, + "StasyCPUCoreTable" : StasyCPUCoreTableModule, "StasyDeviceTable" : StasyDeviceTableModule, "StasyGeoTable" : StasyGeoTableModule, "TrackerPeerList": TrackerPeerListModule, diff --git a/www/webapp/backend/stasy.py b/www/webapp/backend/stasy.py index fb0ad5a9..8dd13651 100644 --- a/www/webapp/backend/stasy.py +++ b/www/webapp/backend/stasy.py @@ -59,6 +59,8 @@ CPU_STRINGS = ( (r"(VIA \w*).*", r"\1"), ) +CPU_CORES = range(1, 9) + class ProfileDict(object): def __init__(self, data): self._data = data @@ -422,7 +424,7 @@ class Stasy(object): return profiles - def query(self, query, archives=False, no_virt=False, all=False): + def query(self, query, archives=False, no_virt=False, all=False, fields=None): db = self._db.profiles if archives: @@ -437,7 +439,7 @@ class Stasy(object): logging.debug("Executing query: %s" % query) - return db.find(query) + return db.find(query, fields=fields) @property def secret_ids(self): @@ -478,6 +480,11 @@ class Stasy(object): return (speed / all.count()) + def get_cpu_bogomips_accumulated(self): + profiles = self.query({}, no_virt=True, fields=["profile.cpu.bogomips"]) + + return sum([int(o["profile"]["cpu"]["bogomips"]) for o in profiles]) + @property def cpu_speed_map(self): cpu_speeds = {} @@ -494,6 +501,17 @@ class Stasy(object): return cpu_speeds + def get_cpu_cores_map(self): + cores = {} + + for i in CPU_CORES: + cores[i] = \ + self.query({ + "profile.cpu.count" : i, + }, no_virt=True).count() + + return cores + def get_memory_map(self): memory = {} diff --git a/www/webapp/handlers_stasy.py b/www/webapp/handlers_stasy.py index e069812e..0f281b74 100644 --- a/www/webapp/handlers_stasy.py +++ b/www/webapp/handlers_stasy.py @@ -79,7 +79,9 @@ class StasyStatsCPUHandler(StasyBaseHandler): return self.render("stasy-stats-cpus.html", cpu_vendors=self.stasy.cpu_vendors_map, average_speed=self.stasy.cpu_speed_average, - cpu_speeds=self.stasy.cpu_speed_map) + cpu_speeds=self.stasy.cpu_speed_map, + cpu_cores=self.stasy.get_cpu_cores_map(), + bogomips=self.stasy.get_cpu_bogomips_accumulated()) class StasyStatsCPUFlagsHandler(StasyBaseHandler): @@ -95,8 +97,6 @@ class StasyStatsCPUFlagsHandler(StasyBaseHandler): for name, flag in flags: kwargs["cpus_" + name] = self.stasy.get_cpu_flag_map(flag) - print kwargs - return self.render("stasy-stats-cpu-flags.html", **kwargs) class StasyStatsMemoryHandler(StasyBaseHandler): diff --git a/www/webapp/ui_modules.py b/www/webapp/ui_modules.py index 01b9c86e..0e7b7a37 100644 --- a/www/webapp/ui_modules.py +++ b/www/webapp/ui_modules.py @@ -146,6 +146,15 @@ class TrackerPeerListModule(UIModule): class StasyTableModule(UIModule): + def _make_percentages(self, items): + total = sum(items.values()) + + for k in items.keys(): + items[k] *= 100 + items[k] /= total + + return items + def render(self, items, sortby="key", reverse=False, percentage=False, flags=False, locale=False): hundred_percent = 0 for v in items.values(): @@ -193,6 +202,18 @@ class StasyTableModule(UIModule): return self.render_string("modules/stasy-table.html", items=items, flags=flags) +class StasyCPUCoreTableModule(StasyTableModule): + def render(self, items): + items = self._make_percentages(items) + + items = items.items() + items.sort() + + return self.render_string("modules/stasy-table.html", items=items, + flags=None #XXX + ) + + class StasyDeviceTableModule(UIModule): def render(self, devices): groups = {}