From 37efc982912c42b5cb5a75bd629f76fb96f51a25 Mon Sep 17 00:00:00 2001 From: Jonathan Creasy Date: Wed, 24 Sep 2014 10:48:05 -0500 Subject: [PATCH] Added configuration for proposed Flume collector --- collectors/0/flume.py | 21 +++++++++++++++++++++ collectors/etc/flume_conf.py | 13 +++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 collectors/etc/flume_conf.py diff --git a/collectors/0/flume.py b/collectors/0/flume.py index d3315df7..711ae143 100755 --- a/collectors/0/flume.py +++ b/collectors/0/flume.py @@ -27,6 +27,10 @@ from collectors.lib import utils +try: + from collectors.etc import flume_conf +except ImportError: + flume_conf = None COLLECTION_INTERVAL = 15 # seconds DEFAULT_TIMEOUT = 10.0 # seconds @@ -58,6 +62,23 @@ def flume_metrics(server): return request(server, "/metrics") def main(argv): + if not (flume_conf and flume_conf.enabled() and flume_conf.get_settings()): + sys.exit(13) + + settings = flume_conf.get_settings() + + if (settings['default_timeout']): + DEFAULT_TIMEOUT = settings['default_timeout'] + + if (settings['default_timeout']): + COLLECTION_INTERVAL = settings['collection_interval'] + + if (settings['flume_host']): + FLUME_HOST = settings['flume_host'] + + if (settings['flume_port']): + FLUME_PORT = settings['flume_port'] + utils.drop_privileges() socket.setdefaulttimeout(DEFAULT_TIMEOUT) server = httplib.HTTPConnection(FLUME_HOST, FLUME_PORT) diff --git a/collectors/etc/flume_conf.py b/collectors/etc/flume_conf.py new file mode 100644 index 00000000..e1acd861 --- /dev/null +++ b/collectors/etc/flume_conf.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +def enabled(): + return False + +def get_settings(): + """Flume Connection Details""" + return { + 'flume_host': "localhost", # Flume Host to Connect to + 'flume_port': 34545, # Flume Port to connect to + 'collection_interval': 15, # seconds, How often to collect metric data + 'default_timeout': 10.0 # seconds + }