# 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/etc/elasticsearch_conf.py
# def get_servers():


import errno
  import json
import socket
import sys
import threading
import time
import re
from collectors.lib import utils
from collectors.etc import elasticsearch_conf
  from http.client import HTTPConnection, OK
  from httplib import HTTPConnection, OK
  # Warning, this should be called inside a lock
  if tags:
    tags = " " + " ".join("%s=%s" % (name.replace(" ",""), value.replace(" ",""))
                          for name, value in tags.items())
  else:
    tags = ""
  # Convert any bool values to int, as opentsdb only accepts int or float.
  if isinstance(value, bool):
      value = int(value)
  print("%s %d %s %s"
         % (metric, ts, value, tags))

def _traverse(metric, stats, ts, tags):
  """
     Recursively traverse the json tree and print out leaf numeric values
     Please make sure you call this inside a lock and don't add locking
     inside this function
  """
  #print metric,stats,ts,tags
  if isinstance(stats,dict):
    if "timestamp" in stats:
      ts = stats["timestamp"] / 1000 # ms -> s
    for key in stats.keys():
      if key != "timestamp":
        _traverse(metric + "." + key, stats[key], ts, tags)
  if isinstance(stats, (list, set, tuple)):
    count = 0
    for value in stats:
      _traverse(metric + "." + str(count), value, ts, tags)
      count += 1

# 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/etc/elasticsearch_conf.py
# def get_servers():


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

  # Warning, this should be called inside a lock
  if tags:
    tags = " " + " ".join("%s=%s" % (name.replace(" ",""), value.replace(" ",""))
                          for name, value in tags.items())
  else:
    tags = ""
  # Convert any bool values to int, as opentsdb only accepts int or float.
  if isinstance(value, bool):
      value = int(value)
  print("%s %d %s %s"
         % (metric, ts, value, tags))

def _traverse(metric, stats, ts, tags):
  """
     Recursively traverse the json tree and print out leaf numeric values
     Please make sure you call this inside a lock and don't add locking
     inside this function
  """
  #print metric,stats,ts,tags
  if isinstance(stats,dict):
    if "timestamp" in stats:
      ts = stats["timestamp"] / 1000 # ms -> s
    for key in stats.keys():
      if key != "timestamp":
        _traverse(metric + "." + key, stats[key], ts, tags)
  if isinstance(stats, (list, set, tuple)):
    count = 0
    for value in stats:
      _traverse(metric + "." + str(count), value, ts, tags)
      count += 1

  if utils.is_numeric(stats) and not isinstance(stats, bool):