Skip to content

Commit

Permalink
Added configuration for proposed Flume collector
Browse files Browse the repository at this point in the history
  • Loading branch information
johann8384 committed Nov 11, 2014
1 parent 0482555 commit 37efc98
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
21 changes: 21 additions & 0 deletions collectors/0/flume.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions collectors/etc/flume_conf.py
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 37efc98

Please sign in to comment.