]> git.ipfire.org Git - collecty.git/blobdiff - collecty/plugins/entropy.py
Split plugins into data sources and graph templates.
[collecty.git] / collecty / plugins / entropy.py
index 7d588d605ec547c4875c68462fe09ec13aad7a09..e1b6952e34b106c37c6c9c7c12bfa5465c702214 100644 (file)
@@ -27,17 +27,8 @@ from ..i18n import _
 
 ENTROPY_FILE = "/proc/sys/kernel/random/entropy_avail"
 
-class PluginEntropy(base.Plugin):
+class GraphTemplateEntropy(base.GraphTemplate):
        name = "entropy"
-       description = "Entropy Plugin"
-
-       rrd_schema = [
-               "DS:entropy:GAUGE:120:0:U",
-               "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:entropy=%(file)s:entropy:AVERAGE",
@@ -53,6 +44,7 @@ class PluginEntropy(base.Plugin):
 
                "LINE3:entropytrend#000000",
        ]
+
        rrd_graph_args = [
                "--title", _("Available entropy"),
                "--vertical-label", _("Bits"),
@@ -60,6 +52,21 @@ class PluginEntropy(base.Plugin):
                "--lower-limit", "0", "--rigid",
        ]
 
+
+class DataSourceEntropy(base.DataSource):
+       name = "entropy"
+       description = "Entropy Data Source"
+
+       templates = [GraphTemplateEntropy,]
+
+       rrd_schema = [
+               "DS:entropy:GAUGE:120:0:U",
+               "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):
                if not os.path.exists(ENTROPY_FILE):