]> git.ipfire.org Git - collecty.git/commitdiff
psi: Add graph template master
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 4 Dec 2021 14:21:57 +0000 (14:21 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 4 Dec 2021 14:21:57 +0000 (14:21 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/collecty/plugins/psi.py

index f9fe0b1085400bc340e2c6023d6a382aaaf6ff01..8f326c1572c652d8b55810dd68a02c38849aa8a0 100644 (file)
 import os
 
 from . import base
+from ..colours import *
+from ..constants import *
+from ..i18n import _
+
+class PSIGraphTemplate(base.GraphTemplate):
+       name = "psi"
+
+       @property
+       def rrd_graph(self):
+               rrd_graph = [
+                       "LINE2:some_avg300%s:%s" % (
+                               YELLOW, LABEL % _("5 Minutes"),
+                       ),
+                       "GPRINT:some_avg300_cur:%s" % FLOAT,
+                       "GPRINT:some_avg300_avg:%s" % FLOAT,
+                       "GPRINT:some_avg300_min:%s" % FLOAT,
+                       "GPRINT:some_avg300_max:%s\\j" % FLOAT,
+
+                       "LINE2:some_avg60%s:%s" % (
+                               ORANGE, LABEL % _("1 Minute"),
+                       ),
+                       "GPRINT:some_avg60_cur:%s" % FLOAT,
+                       "GPRINT:some_avg60_avg:%s" % FLOAT,
+                       "GPRINT:some_avg60_min:%s" % FLOAT,
+                       "GPRINT:some_avg60_max:%s\\j" % FLOAT,
+
+                       "LINE2:some_avg10%s:%s" % (
+                               RED, LABEL % _("10 Seconds"),
+                       ),
+                       "GPRINT:some_avg10_cur:%s" % FLOAT,
+                       "GPRINT:some_avg10_avg:%s" % FLOAT,
+                       "GPRINT:some_avg10_min:%s" % FLOAT,
+                       "GPRINT:some_avg10_max:%s\\j" % FLOAT,
+
+                       # Headline
+                       "COMMENT:%s" % EMPTY_LABEL,
+                       "COMMENT:%s" % (COLUMN % _("Current")),
+                       "COMMENT:%s" % (COLUMN % _("Average")),
+                       "COMMENT:%s" % (COLUMN % _("Minimum")),
+                       "COMMENT:%s\\j" % (COLUMN % _("Maximum")),
+               ]
+
+               return rrd_graph
+
+       upper_limit = 100
+       lower_limit = 0
+
+       @property
+       def graph_title(self):
+               titles = {
+                       "cpu"    : _("Processor Pressure Stall Information"),
+                       "io"     : _("Input/Output Pressure Stall Information"),
+                       "memory" : _("Memory Pressure Stall Information"),
+               }
+
+               try:
+                       return titles[self.object.id]
+               except KeyError:
+                       return _("%s Pressure Stall Information") % self.object.id
+
+       @property
+       def graph_vertical_label(self):
+               return _("Percentage")
+
+       @property
+       def rrd_graph_args(self):
+               return [
+                       "--legend-direction=bottomup",
+               ]
+
 
 class PSIObject(base.Object):
        rrd_schema = [
@@ -93,6 +163,10 @@ class PSIPlugin(base.Plugin):
        name = "psi"
        description = "Pressure Stall Information Plugin"
 
+       templates = [
+               PSIGraphTemplate,
+       ]
+
        @property
        def objects(self):
                for item in os.listdir("/proc/pressure"):