]> git.ipfire.org Git - collecty.git/commitdiff
entropy: New plugin.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 5 Aug 2012 10:36:49 +0000 (10:36 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 5 Aug 2012 10:36:49 +0000 (10:36 +0000)
Collects the amount of kernel entropy.

collecty/plugins/__init__.py
collecty/plugins/entropy.py [new file with mode: 0644]

index 71cf971cf60b765a3281a05b136a2bedc6212135..3e4e349e1d576c482f63b6077d1bcfee2e5e9f76 100644 (file)
 from base import Timer
 
 import cpu
+import entropy
 import loadavg
 import memory
 
 registered_plugins = [
        cpu.PluginCPU,
+       entropy.PluginEntropy,
        loadavg.PluginLoadAvg,
        memory.PluginMemory,
 ]
diff --git a/collecty/plugins/entropy.py b/collecty/plugins/entropy.py
new file mode 100644 (file)
index 0000000..5aa77ec
--- /dev/null
@@ -0,0 +1,56 @@
+#!/usr/bin/python
+###############################################################################
+#                                                                             #
+# collecty - A system statistics collection daemon for IPFire                 #
+# Copyright (C) 2012 IPFire development team                                  #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+import os
+
+import base
+
+ENTROPY_FILE = "/proc/sys/kernel/random/entropy_avail"
+
+class PluginEntropy(base.Plugin):
+       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",
+       ]
+
+       @classmethod
+       def autocreate(cls, collecty, **kwargs):
+               if not os.path.exists(ENTROPY_FILE):
+                       self.log.debug(_("Entropy kernel interface does not exist."))
+                       return
+
+               return cls(collecty, **kwargs)
+
+       def read(self):
+               data = "%s" % self.now
+
+               f = open(ENTROPY_FILE)
+               entropy = f.readline()
+               f.close()
+
+               data += ":%s" % entropy.strip()
+               self.data.append(data)