From: Michael Tremer Date: Sun, 5 Aug 2012 10:36:49 +0000 (+0000) Subject: entropy: New plugin. X-Git-Tag: 0.0.2~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55c283217b68229568d731f7bba05d33e8bad636;p=telemetry.git entropy: New plugin. Collects the amount of kernel entropy. --- diff --git a/collecty/plugins/__init__.py b/collecty/plugins/__init__.py index 71cf971..3e4e349 100644 --- a/collecty/plugins/__init__.py +++ b/collecty/plugins/__init__.py @@ -22,11 +22,13 @@ 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 index 0000000..5aa77ec --- /dev/null +++ b/collecty/plugins/entropy.py @@ -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 . # +# # +############################################################################### + +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)