From 1f07f496743876458396143750f94731e1c51bc6 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 4 Dec 2021 14:21:57 +0000 Subject: [PATCH] psi: Add graph template Signed-off-by: Michael Tremer --- src/collecty/plugins/psi.py | 74 +++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/src/collecty/plugins/psi.py b/src/collecty/plugins/psi.py index f9fe0b1..8f326c1 100644 --- a/src/collecty/plugins/psi.py +++ b/src/collecty/plugins/psi.py @@ -22,6 +22,76 @@ 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"): -- 2.39.2