From 19518d6ec558cf7f93f599a657eb8471f35f61d0 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 1 Nov 2018 13:44:15 +0000 Subject: [PATCH] fireinfo: Add processors page Signed-off-by: Michael Tremer --- Makefile.am | 5 +- src/backend/fireinfo.py | 4 +- src/templates/fireinfo/index.html | 4 + src/templates/fireinfo/processors.html | 99 +++++++++++++++++++ src/templates/fireinfo/stats-cpus-detail.html | 89 ----------------- src/templates/fireinfo/stats-cpus.html | 58 ----------- src/templates/fireinfo/stats-geo.html | 19 ---- src/templates/fireinfo/stats.html | 39 -------- src/web/__init__.py | 8 +- src/web/fireinfo.py | 34 ++----- 10 files changed, 116 insertions(+), 243 deletions(-) create mode 100644 src/templates/fireinfo/processors.html delete mode 100644 src/templates/fireinfo/stats-cpus-detail.html delete mode 100644 src/templates/fireinfo/stats-cpus.html delete mode 100644 src/templates/fireinfo/stats-geo.html delete mode 100644 src/templates/fireinfo/stats.html diff --git a/Makefile.am b/Makefile.am index 7d84d27e..9cd40b72 100644 --- a/Makefile.am +++ b/Makefile.am @@ -141,12 +141,9 @@ templates_fireinfo_DATA = \ src/templates/fireinfo/driver.html \ src/templates/fireinfo/index.html \ src/templates/fireinfo/i-use-1.png \ + src/templates/fireinfo/processors.html \ src/templates/fireinfo/profile.html \ src/templates/fireinfo/releases.html \ - src/templates/fireinfo/stats-cpus-detail.html \ - src/templates/fireinfo/stats-cpus.html \ - src/templates/fireinfo/stats-geo.html \ - src/templates/fireinfo/stats.html \ src/templates/fireinfo/vendor.html \ src/templates/fireinfo/vendors.html diff --git a/src/backend/fireinfo.py b/src/backend/fireinfo.py index e1a07e02..b14edd91 100644 --- a/src/backend/fireinfo.py +++ b/src/backend/fireinfo.py @@ -1860,13 +1860,13 @@ class Fireinfo(Object): def get_common_cpu_flags_by_platform(self, platform, when=None): if platform == "arm": flags = ( - "lpae", "neon", "thumb", "thumb2", "thumbee", "vfpv3", "vfpv4", + "lpae", "neon", "thumb", "thumbee", "vfpv3", "vfpv4", ) elif platform == "x86": flags = ( "aes", "avx", "avx2", "lm", "mmx", "mmxext", "nx", "pae", "pni", "popcnt", "sse", "sse2", "rdrand", "ssse3", "sse4a", - "sse4_1", "sse4_2", "sha", "pclmulqdq", "rdseed", + "sse4_1", "sse4_2", "pclmulqdq", "rdseed", ) else: return diff --git a/src/templates/fireinfo/index.html b/src/templates/fireinfo/index.html index 2fe4deea..77667c80 100644 --- a/src/templates/fireinfo/index.html +++ b/src/templates/fireinfo/index.html @@ -105,6 +105,10 @@ {% end %} + + {{ _("Processor Features") }} + +

{{ _("Architectures") }}

diff --git a/src/templates/fireinfo/processors.html b/src/templates/fireinfo/processors.html new file mode 100644 index 00000000..58daac12 --- /dev/null +++ b/src/templates/fireinfo/processors.html @@ -0,0 +1,99 @@ +{% extends "../base.html" %} + +{% block title %}{{ _("Processors") }}{% end block %} + +{% block container %} +
+
+
+
+

{{ _("Processors") }}

+
+
+
+
+ +
+ {% for platform in flags %} +

{{ platform }}

+ +
+ {% for flag, percentage in flags[platform] %} +
+ {% if flag == "aes" %} + {{ _("AES Instruction Set") }} + {% elif flag == "avx" %} + {{ _("AVX") }} + {% elif flag == "avx2" %} + {{ _("AVX2") }} + {% elif flag == "lpae" %} + {{ _("LPAE") }} + {% elif flag == "mmx" %} + {{ _("MMX") }} + {% elif flag == "mmxext" %} + {{ _("MMX2") }} + {% elif flag == "neon" %} + {{ _("NEON") }} + {% elif flag == "nx" %} + {{ _("No eXecute bit") }} + {% elif flag == "lm" %} + {{ _("Supports 64 bits") }} + {% elif flag == "pae" %} + {{ _("PAE") }} + {% elif flag == "pclmulqdq" %} + {{ _("PCLMULQDQ") }} + {% elif flag == "pni" %} + {{ _("SSE3") }} + {% elif flag == "popcnt" %} + {{ _("POPCNT") }} + {% elif flag == "rdrand" %} + {{ _("RDRAND") }} + {% elif flag == "rdseed" %} + {{ _("RDSEED") }} + {% elif flag == "sha" %} + {{ _("SHA") }} + {% elif flag == "sse" %} + {{ _("SSE") }} + {% elif flag == "sse2" %} + {{ _("SSE2") }} + {% elif flag == "sse4a" %} + {{ _("SSE4a") }} + {% elif flag == "sse4_1" %} + {{ _("SSE4.1") }} + {% elif flag == "sse4_2" %} + {{ _("SSE4.2") }} + {% elif flag == "ssse3" %} + {{ _("SSSE3") }} + {% elif flag == "thumb" %} + {{ _("Thumb") }} + {% elif flag == "thumb2" %} + {{ _("Thumb2") }} + {% elif flag == "thumbee" %} + {{ _("ThumbEE") }} + {% elif flag == "vfpv3" %} + {{ _("VFPv3") }} + {% elif flag == "vfpv4" %} + {{ _("VFPv4") }} + {% elif flag == "virt" %} + {{ _("Virtualization") }} + {% else %} + {{ flag }} + {% end %} +
+ +
+ {% if percentage >= 0.95 %} + {% module ProgressBar(percentage, "success") %} + {% elif percentage >= 0.5 %} + {% module ProgressBar(percentage, "warning") %} + {% elif percentage >= 0.1 %} + {% module ProgressBar(percentage, "info") %} + {% else %} + {% module ProgressBar(percentage, "danger") %} + {% end %} +
+ {% end %} +
+ {% end %} +
+{% end block %} diff --git a/src/templates/fireinfo/stats-cpus-detail.html b/src/templates/fireinfo/stats-cpus-detail.html deleted file mode 100644 index 4c306f02..00000000 --- a/src/templates/fireinfo/stats-cpus-detail.html +++ /dev/null @@ -1,89 +0,0 @@ -{% extends "../base.html" %} - -{% block title %}{{ _("Processors") }}{% end block %} - -{% block body %} - - -

{{ _("CPU Features") }}

-
- {% for flag, percentage in flags %} - {% if percentage >= 0.01 %} -
- {% if flag == "aes" %} - {{ _("AES Instruction Set") }} - {% elif flag == "avx" %} - {{ _("AVX") }} - {% elif flag == "avx2" %} - {{ _("AVX2") }} - {% elif flag == "lpae" %} - {{ _("LPAE") }} - {% elif flag == "mmx" %} - {{ _("MMX") }} - {% elif flag == "mmxext" %} - {{ _("MMX2") }} - {% elif flag == "neon" %} - {{ _("NEON") }} - {% elif flag == "nx" %} - {{ _("No eXecute bit") }} - {% elif flag == "lm" %} - {{ _("Supports 64 bits") }} - {% elif flag == "pae" %} - {{ _("PAE") }} - {% elif flag == "pclmulqdq" %} - {{ _("PCLMULQDQ") }} - {% elif flag == "pni" %} - {{ _("SSE3") }} - {% elif flag == "popcnt" %} - {{ _("POPCNT") }} - {% elif flag == "rdrand" %} - {{ _("RDRAND") }} - {% elif flag == "rdseed" %} - {{ _("RDSEED") }} - {% elif flag == "sha" %} - {{ _("SHA") }} - {% elif flag == "sse" %} - {{ _("SSE") }} - {% elif flag == "sse2" %} - {{ _("SSE2") }} - {% elif flag == "sse4a" %} - {{ _("SSE4a") }} - {% elif flag == "sse4_1" %} - {{ _("SSE4.1") }} - {% elif flag == "sse4_2" %} - {{ _("SSE4.2") }} - {% elif flag == "ssse3" %} - {{ _("SSSE3") }} - {% elif flag == "thumb" %} - {{ _("Thumb") }} - {% elif flag == "thumb2" %} - {{ _("Thumb2") }} - {% elif flag == "thumbee" %} - {{ _("ThumbEE") }} - {% elif flag == "vfpv3" %} - {{ _("VFPv3") }} - {% elif flag == "vfpv4" %} - {{ _("VFPv4") }} - {% elif flag == "virt" %} - {{ _("Virtualization") }} - {% else %} - {{ flag }} - {% end %} -
-
- {% if percentage >= 0.95 %} - {% module ProgressBar(percentage, "success") %} - {% elif percentage >= 0.5 %} - {% module ProgressBar(percentage, "warning") %} - {% elif percentage >= 0.1 %} - {% module ProgressBar(percentage, "info") %} - {% else %} - {% module ProgressBar(percentage, "danger") %} - {% end %} -
- {% end %} - {% end %} -
-{% end block %} diff --git a/src/templates/fireinfo/stats-cpus.html b/src/templates/fireinfo/stats-cpus.html deleted file mode 100644 index 52746f00..00000000 --- a/src/templates/fireinfo/stats-cpus.html +++ /dev/null @@ -1,58 +0,0 @@ -{% extends "../base.html" %} - -{% block title %}{{ _("Processors") }}{% end block %} - -{% block body %} - - -
-
- ({{ _("minimum") }}) -

{{ "%.0f" % clock_speed_min }} {{ _("MHz") }}

-
-
- ({{ _("average") }}) -

{{ "%.0f" % clock_speed_avg }} {{ _("MHz") }}

-
-
- ({{ _("maximum") }}) -

{{ "%.0f" % clock_speed_max }} {{ _("MHz") }}

-
-
- -
-
    -
  • {{ _("CPU Features") }}:
  • - {% for platform in ("x86", "arm") %} -
  • - {{ platform }} -
  • - {% end %} -
-
- -
- -

{{ _("Vendors") }}

-

- This chart shows us which vendors is the most favorite for the CPUs - used in IPFire. -

- -
- {% for vendor, percentage in cpu_vendors %} -
{{ vendor }}
-
{% module ProgressBar(percentage) %}
- {% end %} -
- -

{{ _("Architectures") }}

-
- {% for name, percentage in arch_map %} -
{{ name }}
-
{% module ProgressBar(percentage) %}
- {% end %} -
-{% end block %} diff --git a/src/templates/fireinfo/stats-geo.html b/src/templates/fireinfo/stats-geo.html deleted file mode 100644 index 83dc223a..00000000 --- a/src/templates/fireinfo/stats-geo.html +++ /dev/null @@ -1,19 +0,0 @@ -{% extends "../base.html" %} - -{% block title %}{{ _("Geo Locations") }}{% end block %} - -{% block body %} - - -
-
-

- This chart shows us in which country IPFire is running. -

- - {% module FireinfoGeoTable(geo_locations) %} -
-
-{% end block %} diff --git a/src/templates/fireinfo/stats.html b/src/templates/fireinfo/stats.html deleted file mode 100644 index a763caeb..00000000 --- a/src/templates/fireinfo/stats.html +++ /dev/null @@ -1,39 +0,0 @@ -{% extends "../base.html" %} - -{% block title %}{{ _("Statistics") }}{% end block %} - -{% block body %} - - -
-
- -
- -
-
-

{{ _("Hardware") }}

- -

- {{ _("Processors") }} -

-
- -
-

{{ _("Others") }}

- -

- {{ _("Geo Locations") }} -

-
-
-
-{% end block %} diff --git a/src/web/__init__.py b/src/web/__init__.py index 15a74740..85b58a5c 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -198,15 +198,11 @@ class Application(tornado.web.Application): (r"/profile/([a-z0-9]{40})", fireinfo.ProfileHandler), # Stats + (r"/processors", fireinfo.ProcessorsHandler), (r"/releases", fireinfo.ReleasesHandler), - # Send profiles. + # Send profiles (r"/send/([a-z0-9]+)", fireinfo.ProfileSendHandler), - - # Stats handlers - (r"/statistics", fireinfo.StatsHandler), - (r"/statistics/processors", fireinfo.StatsProcessorsHandler), - (r"/statistics/processors/(arm|x86)", fireinfo.StatsProcessorDetailHandler), ]) # i-use.ipfire.org diff --git a/src/web/fireinfo.py b/src/web/fireinfo.py index a4add7d1..a00eaaac 100644 --- a/src/web/fireinfo.py +++ b/src/web/fireinfo.py @@ -221,36 +221,18 @@ class ReleasesHandler(BaseHandler): return self.render("fireinfo/releases.html", **data) -class StatsHandler(BaseHandler): +class ProcessorsHandler(BaseHandler): def get(self): - self.render("fireinfo/stats.html") + flags = {} + for platform in ("arm", "x86"): + flags[platform] = \ + self.fireinfo.get_common_cpu_flags_by_platform(platform, when=self.when) -class StatsProcessorsHandler(BaseHandler): - def get(self): - avg, stddev, min, max = self.fireinfo.get_cpu_clock_speeds(when=self.when) - arch_map = self.fireinfo.get_arch_map(when=self.when) - - data = { - "arch_map" : arch_map, - "cpu_vendors" : self.fireinfo.get_cpu_vendors_map(when=self.when), - "clock_speed_avg" : avg, - "clock_speed_stddev" : stddev, - "clock_speed_min" : min, - "clock_speed_max" : max, - } - - return self.render("fireinfo/stats-cpus.html", **data) - - -class StatsProcessorDetailHandler(BaseHandler): - def get(self, platform): - assert platform in ("arm", "x86") - - flags = self.fireinfo.get_common_cpu_flags_by_platform(platform, when=self.when) + # Cache for 1h + self.set_expires(3600) - return self.render("fireinfo/stats-cpus-detail.html", - platform=platform, flags=flags) + return self.render("fireinfo/processors.html", flags=flags) class VendorsHandler(BaseHandler): -- 2.39.5