diff --git a/conf/diamond.conf.example b/conf/diamond.conf.example index 8979df28a..24f88401b 100644 --- a/conf/diamond.conf.example +++ b/conf/diamond.conf.example @@ -212,3 +212,16 @@ args = ('/var/log/diamond/diamond.log', 'midnight', 1, 7) format = [%(asctime)s] [%(threadName)s] %(message)s datefmt = +################################################################################ +### Options for config merging +# [configs] +# path = "/etc/diamond/configs/" +# extension = ".conf" +#------------------------------------------------------------------------------- +# Example: +# /etc/diamond/configs/net.conf +# [collectors] +# +# [[NetworkCollector]] +# enabled = True + diff --git a/src/diamond/server.py b/src/diamond/server.py index e0d33e136..d458349ad 100644 --- a/src/diamond/server.py +++ b/src/diamond/server.py @@ -42,13 +42,19 @@ def __init__(self, config): def load_config(self): """ - Load the full config + Load the full config / merge splitted configs if configured """ configfile = os.path.abspath(self.config['configfile']) config = configobj.ConfigObj(configfile) config['configfile'] = self.config['configfile'] - + try: + for cfgfile in os.listdir(config['configs']['path']): + if cfgfile.endswith(config['configs']['extension']): + newconfig = configobj.ConfigObj(config['configs']['path'] + cfgfile) + config.merge(newconfig) + except KeyError: + pass self.config = config def load_handler(self, fqcn):