]> git.ipfire.org Git - collecty.git/blobdiff - collecty/plugins/memory.py
Split plugins into data sources and graph templates.
[collecty.git] / collecty / plugins / memory.py
index 952442a60233a73c26d2a3ffcb01a88133e33a0a..64cc820b285a314e373869db7fd6d4fef04295d2 100644 (file)
@@ -25,21 +25,8 @@ import base
 
 from ..i18n import _
 
-class PluginMemory(base.Plugin):
+class GraphTemplateMemory(base.GraphTemplate):
        name = "memory"
-       description = "Memory Usage Plugin"
-
-       rrd_schema = [
-               "DS:used:GAUGE:120:0:100",
-               "DS:cached:GAUGE:120:0:100",
-               "DS:buffered:GAUGE:120:0:100",
-               "DS:free:GAUGE:120:0:100",
-               "DS:swap:GAUGE:120:0:100",
-               "RRA:AVERAGE:0.5:1:2160",
-               "RRA:AVERAGE:0.5:5:2016",
-               "RRA:AVERAGE:0.5:15:2880",
-               "RRA:AVERAGE:0.5:60:8760",
-       ]
 
        rrd_graph = [
                "DEF:used=%(file)s:used:AVERAGE",
@@ -88,6 +75,7 @@ class PluginMemory(base.Plugin):
                "GPRINT:swapmin:%12s\:" % _("Minimum") + " %6.2lf",
                "GPRINT:swapavg:%12s\:" % _("Average") + " %6.2lf\\n",
        ]
+
        rrd_graph_args = [
                "--title", _("Memory Usage"),
                "--vertical-label", _("Percent"),
@@ -98,6 +86,25 @@ class PluginMemory(base.Plugin):
                "--rigid",
        ]
 
+
+class DataSourceMemory(base.DataSource):
+       name = "memory"
+       description = "Memory Usage Data Source"
+
+       templates = [GraphTemplateMemory,]
+
+       rrd_schema = [
+               "DS:used:GAUGE:120:0:100",
+               "DS:cached:GAUGE:120:0:100",
+               "DS:buffered:GAUGE:120:0:100",
+               "DS:free:GAUGE:120:0:100",
+               "DS:swap:GAUGE:120:0:100",
+               "RRA:AVERAGE:0.5:1:2160",
+               "RRA:AVERAGE:0.5:5:2016",
+               "RRA:AVERAGE:0.5:15:2880",
+               "RRA:AVERAGE:0.5:60:8760",
+       ]
+
        @classmethod
        def autocreate(cls, collecty, **kwargs):
                # Every system has got memory.