]
-class EntropyPlugin(base.Plugin):
- name = "entropy"
- description = "Entropy Data Source"
-
- templates = [GraphTemplateEntropy,]
-
+class EntropyObject(base.Object):
rrd_schema = [
"DS:entropy:GAUGE:0:U",
]
- @classmethod
- def autocreate(cls, collecty, **kwargs):
- if not os.path.exists(ENTROPY_FILE):
- self.log.debug(_("Entropy kernel interface does not exist."))
- return
+ @property
+ def id(self):
+ return "default"
- return cls(collecty, **kwargs)
+ def collect(self):
+ with open(ENTROPY_FILE) as f:
+ return f.readline().strip()
- def read(self):
- f = None
- try:
- f = open(ENTROPY_FILE)
- entropy = f.readline()
+class EntropyPlugin(base.Plugin):
+ name = "entropy"
+ description = "Entropy Plugin"
+
+ templates = [GraphTemplateEntropy,]
+
+ @property
+ def objects(self):
+ if not os.path.exists(ENTROPY_FILE):
+ self.log.debug(_("Entropy kernel interface does not exist"))
+ return []
- return entropy.strip()
- finally:
- if f:
- f.close()
+ return [EntropyObject(self)]