]> git.ipfire.org Git - ipfire.org.git/commitdiff
fireinfo: Display core count table and accumulated bogomips.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 22 Jan 2011 12:01:35 +0000 (13:01 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 22 Jan 2011 12:01:35 +0000 (13:01 +0100)
www/templates/stasy-stats-cpus.html
www/translations/de_DE.csv
www/webapp/__init__.py
www/webapp/backend/stasy.py
www/webapp/handlers_stasy.py
www/webapp/ui_modules.py

index 847423138dce0c447ea0bd0ad6d02c141e724726..e34fff2a3fda0186ca1ad6ada486deea7a3de109 100644 (file)
        <h3>{{ _("Speed") }}</h3>
        <p>
                {{ _("The average speed of all systems in the database is: <strong>%.2f MHz</strong>.") % average_speed }}
+               <br />
+               {{ _("All together, there are <strong>%s bogomips</strong> out there.") % locale.friendly_number(bogomips) }}
        </p>
        {{ modules.StasyTable(cpu_speeds) }}
 
+       <h3>{{ _("CPU cores counter") }}</h3>
+       <p>
+               {{ _("See a breakdown of the CPU cores that are installed on the IPFire systems.") }}
+       </p>
+       {{ modules.StasyCPUCoreTable(cpu_cores) }}
+
        <p class="links">
                <a href="cpuflags">{{ _("See statistics about common CPU flags") }}</a>
        </p>
index cbaa0d34fe22b576ef209dc9d877f6d41dca14ef..89f1133b8949d679e8a1ebeae9d3eb0dd00dfa40 100644 (file)
 "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 <strong>%s bogomips</strong> out there.","Insgesamt bringen es alle Systeme auf <strong>%s bogomips</strong>."
index 9dbb16fdf301071004da4df83e6856731d46471e..9574a64688ed70e8b998416fe796da3432606874 100644 (file)
@@ -37,6 +37,7 @@ class Application(tornado.web.Application):
                                "SidebarBanner"  : SidebarBannerModule,
                                "SidebarRelease" : SidebarReleaseModule,
                                "StasyTable"     : StasyTableModule,
+                               "StasyCPUCoreTable" : StasyCPUCoreTableModule,
                                "StasyDeviceTable" : StasyDeviceTableModule,
                                "StasyGeoTable"  : StasyGeoTableModule,
                                "TrackerPeerList": TrackerPeerListModule,
index fb0ad5a974ba803a0601baf0bf2ecd20db4e0f3f..8dd1365137ac57cc28befce618dfa19970e31bf0 100644 (file)
@@ -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 = {}
 
index e069812e4e040214faee1640840e79c026fe02d4..0f281b74d8b67344d5597988b043e55caf547e8f 100644 (file)
@@ -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):
index 01b9c86e04cf47f97c0e14e605a3634045c44526..0e7b7a37c61e66053dd6df22b31253142f75ca48 100644 (file)
@@ -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 = {}