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 = [
name = "psi"
description = "Pressure Stall Information Plugin"
+ templates = [
+ PSIGraphTemplate,
+ ]
+
@property
def objects(self):
for item in os.listdir("/proc/pressure"):