]> git.ipfire.org Git - oddments/collecty.git/commitdiff
df: Refactor graphs
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 24 Sep 2020 12:37:37 +0000 (12:37 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 24 Sep 2020 12:37:37 +0000 (12:37 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/collecty/constants.py
src/collecty/plugins/df.py

index f4b50e8bd907c13f8d8aa808cc4a3cca93d23dbe..bd159f13ed0d84004343de61d369f1eae965db7c 100644 (file)
@@ -67,12 +67,15 @@ GRAPH_DEFAULT_WIDTH = 768
 GRAPH_DEFAULT_HEIGHT = 480
 
 # Default column widths
-LABEL       = "%-24s"
-EMPTY_LABEL = "%26s" % ""
-
-COLUMN      = "%16s"
-PERCENTAGE  = "%13.2lf%%"
-INTEGER     = "%16.0lf"
+LABEL         = "%-24s"
+EMPTY_LABEL   = "%26s" % ""
+
+COLUMN        = "%16s"
+PERCENTAGE    = "%13.2lf%%"
+INTEGER       = "%16.0lf"
+LARGE_INTEGER = "%14.0lf %s"
+FLOAT         = "%14.2lf"
+LARGE_FLOAT   = "%12.2lf %s"
 
 EMPTY_LINE = "COMMENT: \\n"
 
index 3a8cc6adc475e049b00ebe5efa6ae1b02cba161a..7fef88a550bbf79bcb607c1266782cdcfc4067fd 100644 (file)
@@ -36,27 +36,31 @@ class GraphTemplateDiskUsage(base.GraphTemplate):
                _ = self.locale.translate
 
                return [
-                       # Calculate the percentage of the currently used
-                       # space since this is helps the user very much to
-                       # judge
-                       "CDEF:percentage_used=100,used,*,used,free,+,/",
-                       "VDEF:percentage_used_now=percentage_used,LAST",
-                       "CDEF:percentage_left=100,percentage_used,-",
-                       "VDEF:percentage_left_now=percentage_left,LAST",
+                       "COMMENT:%s" % EMPTY_LABEL,
+                       "COMMENT:%s" % (COLUMN % _("Current")),
+                       "COMMENT:%s" % (COLUMN % _("Average")),
+                       "COMMENT:%s" % (COLUMN % _("Minimum")),
+                       "COMMENT:%s\\j" % (COLUMN % _("Maximum")),
 
                        # Area for the used space
-                       "AREA:used%s:%s" % (transparency(LIGHT_RED, AREA_OPACITY), _("Used")),
-                       "GPRINT:percentage_used_now: (%6.2lf%%)",
-                       "GPRINT:used_cur:%12s\:" % _("Current") + " %9.2lf%s",
-                       "GPRINT:used_min:%12s\:" % _("Minimum") + " %9.2lf%s",
-                       "GPRINT:used_max:%12s\:" % _("Maximum") + " %9.2lf%s",
+                       "AREA:used%s:%s" % (
+                               transparency(LIGHT_RED, AREA_OPACITY),
+                               LABEL % _("Used"),
+                       ),
+                       "GPRINT:used_cur:%s" % LARGE_FLOAT,
+                       "GPRINT:used_avg:%s" % LARGE_FLOAT,
+                       "GPRINT:used_min:%s" % LARGE_FLOAT,
+                       "GPRINT:used_max:%s\\j" % LARGE_FLOAT,
 
                        # Stacked area of unused space
-                       "AREA:free%s:%s:STACK" % (transparency(LIGHT_GREEN, AREA_OPACITY), _("Free")),
-                       "GPRINT:percentage_left_now: (%6.2lf%%)",
-                       "GPRINT:free_cur:%12s\:" % _("Current") + " %9.2lf%s",
-                       "GPRINT:free_min:%12s\:" % _("Minimum") + " %9.2lf%s",
-                       "GPRINT:free_max:%12s\:" % _("Maximum") + " %9.2lf%s",
+                       "AREA:free%s:%s:STACK" % (
+                               transparency(LIGHT_GREEN, AREA_OPACITY),
+                               LABEL % _("Free"),
+                       ),
+                       "GPRINT:free_cur:%s" % LARGE_FLOAT,
+                       "GPRINT:free_avg:%s" % LARGE_FLOAT,
+                       "GPRINT:free_min:%s" % LARGE_FLOAT,
+                       "GPRINT:free_max:%s\\j" % LARGE_FLOAT,
 
                        # Add contour lines for the areas
                        "LINE:used%s" % LIGHT_RED,
@@ -83,25 +87,31 @@ class GraphTemplateInodeUsage(base.GraphTemplate):
                _ = self.locale.translate
 
                rrd_graph = [
-                       # Calculate the percentage of the currently used
-                       # inodes since this is helps the user very much to
-                       # judge
-                       "CDEF:percentage_used=100,inodes_used,*,inodes_used,inodes_free,+,/",
-                       "CDEF:percentage_left=100,percentage_used,-",
+                       "COMMENT:%s" % EMPTY_LABEL,
+                       "COMMENT:%s" % (COLUMN % _("Current")),
+                       "COMMENT:%s" % (COLUMN % _("Average")),
+                       "COMMENT:%s" % (COLUMN % _("Minimum")),
+                       "COMMENT:%s\\j" % (COLUMN % _("Maximum")),
 
                        # Area for the used inodes
-                       "AREA:inodes_used%s:%s" % (lighten(LIGHT_RED, .66), _("Used")),
-                       "GPRINT:percentage_used_now: (%6.2lf%%)",
-                       "GPRINT:inodes_used_cur:%12s\:" % _("Current") + " %9.2lf%s",
-                       "GPRINT:inodes_used_min:%12s\:" % _("Minimum") + " %9.2lf%s",
-                       "GPRINT:inodes_used_max:%12s\:" % _("Maximum") + " %9.2lf%s",
+                       "AREA:inodes_used%s:%s" % (
+                               transparency(LIGHT_RED, AREA_OPACITY),
+                               LABEL % _("Used"),
+                       ),
+                       "GPRINT:inodes_used_cur:%s" % LARGE_FLOAT,
+                       "GPRINT:inodes_used_avg:%s" % LARGE_FLOAT,
+                       "GPRINT:inodes_used_min:%s" % LARGE_FLOAT,
+                       "GPRINT:inodes_used_max:%s\\j" % LARGE_FLOAT,
 
                        # Stacked area of unused inodes
-                       "AREA:inodes_free%s:%s:STACK" % (lighten(LIGHT_GREEN, .66), _("Free")),
-                       "GPRINT:percentage_left_now: (%6.2lf%%)",
-                       "GPRINT:inodes_free_cur:%12s\:" % _("Current") + " %9.2lf%s",
-                       "GPRINT:inodes_free_min:%12s\:" % _("Minimum") + " %9.2lf%s",
-                       "GPRINT:inodes_free_max:%12s\:" % _("Maximum") + " %9.2lf%s",
+                       "AREA:inodes_free%s:%s:STACK" % (
+                               transparency(LIGHT_GREEN, AREA_OPACITY),
+                               LABEL % _("Free"),
+                       ),
+                       "GPRINT:inodes_free_cur:%s" % LARGE_FLOAT,
+                       "GPRINT:inodes_free_avg:%s" % LARGE_FLOAT,
+                       "GPRINT:inodes_free_min:%s" % LARGE_FLOAT,
+                       "GPRINT:inodes_free_max:%s\\j" % LARGE_FLOAT,
 
                        # Add contour lines for the areas
                        "LINE:inodes_used%s" % LIGHT_RED,