From: Michael Tremer Date: Thu, 24 Sep 2020 12:37:37 +0000 (+0000) Subject: df: Refactor graphs X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=97cb4beadbd98e2819d8b51f9080c05965f3894b;p=collecty.git df: Refactor graphs Signed-off-by: Michael Tremer --- diff --git a/src/collecty/constants.py b/src/collecty/constants.py index f4b50e8..bd159f1 100644 --- a/src/collecty/constants.py +++ b/src/collecty/constants.py @@ -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" diff --git a/src/collecty/plugins/df.py b/src/collecty/plugins/df.py index 3a8cc6a..7fef88a 100644 --- a/src/collecty/plugins/df.py +++ b/src/collecty/plugins/df.py @@ -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,