# Path: collectors/lib/utils.py
# PY3 = sys.version_info[0] > 2
# USER = "nobody"
# def drop_privileges(user=USER):
# def is_sockfile(path):
# def err(msg):
#     def is_numeric(value):
#     def is_numeric(value):


import errno
  import json
import socket
import sys
import time
from collectors.lib import utils
  from collectors.etc import flume_conf
    from http.client import HTTPConnection, OK
    from httplib import HTTPConnection, OK
def request(server, uri):
  """Does a GET request of the given uri on the given HTTPConnection."""
  server.request("GET", uri)
  resp = server.getresponse()
  if resp.status != OK:
    raise FlumeError(resp)
  return json.loads(resp.read())


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']


# Path: collectors/lib/utils.py
# PY3 = sys.version_info[0] > 2
# USER = "nobody"
# def drop_privileges(user=USER):
# def is_sockfile(path):
# def err(msg):
#     def is_numeric(value):
#     def is_numeric(value):


# Path: collectors/0/flume.py
import errno
  import json
import socket
import sys
import time
from collectors.lib import utils
  from collectors.etc import flume_conf
    from http.client import HTTPConnection, OK
    from httplib import HTTPConnection, OK

def request(server, uri):
  """Does a GET request of the given uri on the given HTTPConnection."""
  server.request("GET", uri)
  resp = server.getresponse()
  if resp.status != OK:
    raise FlumeError(resp)
  return json.loads(resp.read())


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()