]>
git.ipfire.org Git - collecty.git/blob - collecty/__init__.py
2 ###############################################################################
4 # collecty - A system statistics collection daemon for IPFire #
5 # Copyright (C) 2012 IPFire development team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 import ConfigParser
as configparser
28 class ConfigError(Exception):
31 class Collecty(object):
33 self
.config
= configparser
.ConfigParser()
36 def read_config(self
, config
):
37 self
.config
.read(config
)
39 for section
in self
.config
.sections():
41 plugin
= self
.config
.get(section
, "plugin")
42 plugin
= plugins
.find(plugin
)
43 except configparser
.NoOptionError
:
44 raise ConfigError
, "Syntax error in configuration: plugin option is missing."
46 raise Exception, "Plugin configuration error: Maybe plugin wasn't found? %s" % plugin
49 for (key
, value
) in self
.config
.items(section
):
54 kwargs
["file"] = section
56 i
= plugin(self
, **kwargs
)
57 self
.instances
.append(i
)
59 def debug(self
, message
):
63 signal
.signal(signal
.SIGTERM
, lambda *args
: self
.shutdown())
65 for i
in self
.instances
:
69 for i
in self
.instances
:
70 self
.debug("Stopping %s..." % i
)