From fea0113c29d24bde19b04c8cbf7a9ce0684e6e0d Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 5 May 2015 17:16:33 +0000 Subject: [PATCH] Remove support for reading configuration files We are trying for a zero-conf approach here because we assume that a system is constantly changing and therefore is a static configuration almost a hundred percent useless. --- example.conf | 12 ------------ src/collecty/daemon.py | 26 -------------------------- src/collectyd | 8 ++------ 3 files changed, 2 insertions(+), 44 deletions(-) delete mode 100644 example.conf diff --git a/example.conf b/example.conf deleted file mode 100644 index 6136dee..0000000 --- a/example.conf +++ /dev/null @@ -1,12 +0,0 @@ -# -# Example configuration file for collecty -# - -[cpu.rrd] -plugin=cpu - -[load.rrd] -plugin=load - -[mem.rrd] -plugin=mem diff --git a/src/collecty/daemon.py b/src/collecty/daemon.py index 6d6769b..00a4431 100644 --- a/src/collecty/daemon.py +++ b/src/collecty/daemon.py @@ -21,8 +21,6 @@ import signal -import ConfigParser as configparser - import plugins from constants import * @@ -36,7 +34,6 @@ class Collecty(object): SUBMIT_INTERVAL = 300 def __init__(self, debug=False): - self.config = configparser.ConfigParser() self.data_sources = [] # Indicates whether this process should be running or not. @@ -65,29 +62,6 @@ class Collecty(object): self.data_sources += ret - def read_config(self, config): - self.config.read(config) - - for section in self.config.sections(): - try: - data_source = self.config.get(section, "data_source") - data_source = plugins.find(data_source) - except configparser.NoOptionError: - raise ConfigError, "Syntax error in configuration: plugin option is missing." - except: - raise Exception, "Plugin configuration error: Maybe plugin wasn't found? %s" % data_source - - kwargs = {} - for (key, value) in self.config.items(section): - if key == "plugin": - continue - - kwargs[key] = value - kwargs["file"] = section - - ds = data_source(self, **kwargs) - self.data_sources.append(ds) - def run(self): # Register signal handlers. self.register_signal_handler() diff --git a/src/collectyd b/src/collectyd index 32caafa..4813811 100755 --- a/src/collectyd +++ b/src/collectyd @@ -25,10 +25,10 @@ import sys import collecty # Parse command line options. -op = optparse.OptionParser(usage="usage: %prog [options] ... ") +op = optparse.OptionParser(usage="usage: %prog [options]") op.add_option("-d", "--debug", action="store_true", default=False, help="Enable debug logging.") -(options, configfiles) = op.parse_args() +(options, args) = op.parse_args() # Initialize the settings for this Collecty instance. settings = { @@ -38,10 +38,6 @@ settings = { # Initialize the application. c = collecty.Collecty(**settings) -# Read all configuration files. -for configfile in configfiles: - c.read_config(configfile) - # Run. c.run() -- 2.39.2