]> git.ipfire.org Git - collecty.git/commitdiff
processor: Redesign graph
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 24 Sep 2020 12:00:24 +0000 (12:00 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 24 Sep 2020 12:00:24 +0000 (12:00 +0000)
Justify everything to use the full width and remove
idle percentages.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/collecty/constants.py
src/collecty/plugins/processor.py

index bb38435d90c834d60019527739dca3a54cbabaaf..6c7a610d4be492f3928ff851d2a80752ab61dbf7 100644 (file)
@@ -52,9 +52,6 @@ GRAPH_DEFAULT_ARGUMENTS = (
 
        # Brand all generated graphs.
        "--watermark", _("Created by collecty"),
-
-       # Justify all text
-       "TEXTALIGN:justified",
 )
 
 INTERVALS = {
@@ -69,5 +66,12 @@ INTERVALS = {
 GRAPH_DEFAULT_WIDTH = 768
 GRAPH_DEFAULT_HEIGHT = 480
 
+# Default column widths
+LEGEND     = "%16s"
+LABEL      = "%-14s"
+PERCENTAGE = "%13.2lf%%"
+
+EMPTY_LINE = "COMMENT: \\n"
+
 THUMBNAIL_DEFAULT_WIDTH = 80
 THUMBNAIL_DEFAULT_HEIGHT = 20
index 26d6dc8d0c8417561d777dca704fa1b064e1c3b0..5f6ab466a4053351bb478b70edb6c5c3d92a9664 100644 (file)
@@ -24,6 +24,7 @@ import multiprocessing
 from . import base
 
 from ..colours import *
+from ..constants import *
 
 class GraphTemplateProcessor(base.GraphTemplate):
        name = "processor"
@@ -39,72 +40,88 @@ class GraphTemplateProcessor(base.GraphTemplate):
                        # Add idle to get the total number of cycles
                        "CDEF:total=usage,idle,+",
 
+                       # Headline
+                       "COMMENT:%s" % (LEGEND % ""),
+                       "COMMENT:%s" % (LEGEND % _("Current")),
+                       "COMMENT:%s" % (LEGEND % _("Average")),
+                       "COMMENT:%s" % (LEGEND % _("Minimum")),
+                       "COMMENT:%s\\j" % (LEGEND % _("Maximum")),
+
+                       "CDEF:usage_p=100,usage,*,total,/",
+                       "COMMENT:  %s" % (LABEL % _("Total")),
+                       "GPRINT:usage_p_cur:%s" % PERCENTAGE,
+                       "GPRINT:usage_p_avg:%s" % PERCENTAGE,
+                       "GPRINT:usage_p_min:%s" % PERCENTAGE,
+                       "GPRINT:usage_p_max:%s\\j" % PERCENTAGE,
+
+                       EMPTY_LINE,
+
                        "CDEF:user_p=100,user,*,total,/",
-                       "AREA:user_p%s:%-15s" % (CPU_USER, _("User")),
-                       "GPRINT:user_p_max:%12s\:" % _("Maximum") + " %6.2lf%%",
-                       "GPRINT:user_p_min:%12s\:" % _("Minimum") + " %6.2lf%%",
-                       "GPRINT:user_p_avg:%12s\:" % _("Average") + " %6.2lf%%",
+                       "AREA:user_p%s:%s" % (CPU_USER, LABEL % _("User")),
+                       "GPRINT:user_p_cur:%s" % PERCENTAGE,
+                       "GPRINT:user_p_avg:%s" % PERCENTAGE,
+                       "GPRINT:user_p_min:%s" % PERCENTAGE,
+                       "GPRINT:user_p_max:%s\\j" % PERCENTAGE,
 
                        "CDEF:nice_p=100,nice,*,total,/",
-                       "STACK:nice_p%s:%-15s" % (CPU_NICE, _("Nice")),
-                       "GPRINT:nice_p_max:%12s\:" % _("Maximum") + " %6.2lf%%",
-                       "GPRINT:nice_p_min:%12s\:" % _("Minimum") + " %6.2lf%%",
-                       "GPRINT:nice_p_avg:%12s\:" % _("Average") + " %6.2lf%%",
+                       "STACK:nice_p%s:%s" % (CPU_NICE, LABEL % _("Nice")),
+                       "GPRINT:nice_p_cur:%s" % PERCENTAGE,
+                       "GPRINT:nice_p_avg:%s" % PERCENTAGE,
+                       "GPRINT:nice_p_min:%s" % PERCENTAGE,
+                       "GPRINT:nice_p_max:%s\\j" % PERCENTAGE,
 
                        "CDEF:sys_p=100,sys,*,total,/",
-                       "STACK:sys_p%s:%-15s" % (CPU_SYS, _("System")),
-                       "GPRINT:sys_p_max:%12s\:" % _("Maximum") + " %6.2lf%%",
-                       "GPRINT:sys_p_min:%12s\:" % _("Minimum") + " %6.2lf%%",
-                       "GPRINT:sys_p_avg:%12s\:" % _("Average") + " %6.2lf%%",
+                       "STACK:sys_p%s:%s" % (CPU_SYS, LABEL % _("System")),
+                       "GPRINT:sys_p_cur:%s" % PERCENTAGE,
+                       "GPRINT:sys_p_avg:%s" % PERCENTAGE,
+                       "GPRINT:sys_p_min:%s" % PERCENTAGE,
+                       "GPRINT:sys_p_max:%s\\j" % PERCENTAGE,
 
                        "CDEF:wait_p=100,wait,*,total,/",
-                       "STACK:wait_p%s:%-15s" % (CPU_WAIT, _("Wait")),
-                       "GPRINT:wait_p_max:%12s\:" % _("Maximum") + " %6.2lf%%",
-                       "GPRINT:wait_p_min:%12s\:" % _("Minimum") + " %6.2lf%%",
-                       "GPRINT:wait_p_avg:%12s\:" % _("Average") + " %6.2lf%%",
+                       "STACK:wait_p%s:%s" % (CPU_WAIT, LABEL % _("Wait")),
+                       "GPRINT:wait_p_cur:%s" % PERCENTAGE,
+                       "GPRINT:wait_p_avg:%s" % PERCENTAGE,
+                       "GPRINT:wait_p_min:%s" % PERCENTAGE,
+                       "GPRINT:wait_p_max:%s\\j" % PERCENTAGE,
 
                        "CDEF:irq_p=100,irq,*,total,/",
-                       "STACK:irq_p%s:%-15s" % (CPU_IRQ, _("Interrupt")),
-                       "GPRINT:irq_p_max:%12s\:" % _("Maximum") + " %6.2lf%%",
-                       "GPRINT:irq_p_min:%12s\:" % _("Minimum") + " %6.2lf%%",
-                       "GPRINT:irq_p_avg:%12s\:" % _("Average") + " %6.2lf%%",
+                       "STACK:irq_p%s:%s" % (CPU_IRQ, LABEL % _("Interrupt")),
+                       "GPRINT:irq_p_cur:%s" % PERCENTAGE,
+                       "GPRINT:irq_p_avg:%s" % PERCENTAGE,
+                       "GPRINT:irq_p_min:%s" % PERCENTAGE,
+                       "GPRINT:irq_p_max:%s\\j" % PERCENTAGE,
 
                        "CDEF:sirq_p=100,sirq,*,total,/",
-                       "STACK:sirq_p%s:%-15s" % (CPU_SIRQ, _("Soft Interrupt")),
-                       "GPRINT:sirq_p_max:%12s\:" % _("Maximum") + " %6.2lf%%",
-                       "GPRINT:sirq_p_min:%12s\:" % _("Minimum") + " %6.2lf%%",
-                       "GPRINT:sirq_p_avg:%12s\:" % _("Average") + " %6.2lf%%",
+                       "STACK:sirq_p%s:%s" % (CPU_SIRQ, LABEL % _("Soft Interrupt")),
+                       "GPRINT:sirq_p_cur:%s" % PERCENTAGE,
+                       "GPRINT:sirq_p_avg:%s" % PERCENTAGE,
+                       "GPRINT:sirq_p_min:%s" % PERCENTAGE,
+                       "GPRINT:sirq_p_max:%s\\j" % PERCENTAGE,
 
                        "CDEF:steal_p=100,steal,*,total,/",
-                       "STACK:steal_p%s:%-15s" % (CPU_STEAL, _("Steal")),
-                       "GPRINT:steal_p_max:%12s\:" % _("Maximum") + " %6.2lf%%",
-                       "GPRINT:steal_p_min:%12s\:" % _("Minimum") + " %6.2lf%%",
-                       "GPRINT:steal_p_avg:%12s\:" % _("Average") + " %6.2lf%%",
+                       "STACK:steal_p%s:%s" % (CPU_STEAL, LABEL % _("Steal")),
+                       "GPRINT:steal_p_cur:%s" % PERCENTAGE,
+                       "GPRINT:steal_p_avg:%s" % PERCENTAGE,
+                       "GPRINT:steal_p_min:%s" % PERCENTAGE,
+                       "GPRINT:steal_p_max:%s\\j" % PERCENTAGE,
 
                        "CDEF:guest_p=100,guest,*,total,/",
-                       "STACK:guest_p%s:%-15s" % (CPU_GUEST, _("Guest")),
-                       "GPRINT:guest_p_max:%12s\:" % _("Maximum") + " %6.2lf%%",
-                       "GPRINT:guest_p_min:%12s\:" % _("Minimum") + " %6.2lf%%",
-                       "GPRINT:guest_p_avg:%12s\:" % _("Average") + " %6.2lf%%",
+                       "STACK:guest_p%s:%s" % (CPU_GUEST, LABEL % _("Guest")),
+                       "GPRINT:guest_p_cur:%s" % PERCENTAGE,
+                       "GPRINT:guest_p_avg:%s" % PERCENTAGE,
+                       "GPRINT:guest_p_min:%s" % PERCENTAGE,
+                       "GPRINT:guest_p_max:%s\\j" % PERCENTAGE,
 
                        "CDEF:guest_nice_p=100,guest_nice,*,total,/",
-                       "STACK:guest_nice_p%s:%-15s" % (CPU_GUEST_NICE, _("Guest Nice")),
-                       "GPRINT:guest_nice_p_max:%12s\:" % _("Maximum") + " %6.2lf%%",
-                       "GPRINT:guest_nice_p_min:%12s\:" % _("Minimum") + " %6.2lf%%",
-                       "GPRINT:guest_nice_p_avg:%12s\:" % _("Average") + " %6.2lf%%",
-
-                       "CDEF:usage_p=100,usage,*,total,/",
-                       "COMMENT:  %-15s" % _("Usage"),
-                       "GPRINT:usage_p_max:%12s\:" % _("Maximum") + " %6.2lf%%",
-                       "GPRINT:usage_p_min:%12s\:" % _("Minimum") + " %6.2lf%%",
-                       "GPRINT:usage_p_avg:%12s\:" % _("Average") + " %6.2lf%%",
+                       "STACK:guest_nice_p%s:%s" % (CPU_GUEST_NICE, LABEL % _("Guest Nice")),
+                       "GPRINT:guest_nice_p_cur:%s" % PERCENTAGE,
+                       "GPRINT:guest_nice_p_avg:%s" % PERCENTAGE,
+                       "GPRINT:guest_nice_p_min:%s" % PERCENTAGE,
+                       "GPRINT:guest_nice_p_max:%s\\j" % PERCENTAGE,
 
                        "CDEF:idle_p=100,idle,*,total,/",
-                       "STACK:idle_p%s:%-15s" % (CPU_IDLE, _("Idle")),
-                       "GPRINT:idle_p_max:%12s\:" % _("Maximum") + " %6.2lf%%",
-                       "GPRINT:idle_p_min:%12s\:" % _("Minimum") + " %6.2lf%%",
-                       "GPRINT:idle_p_avg:%12s\:" % _("Average") + " %6.2lf%%",
-               ]
+                       "STACK:idle_p%s" % CPU_IDLE,
+       ]
 
        upper_limit = 100
        lower_limit = 0