"""
handler to flush stats to [Netuitive](http://www.netuitive.com)
# Dependencies

# Configuration
Enable handler

  * handlers = diamond.handler.netuitive_cloud.NetuitiveHandler

  * url = https://api.app.netuitive.com/ingest/infrastructure
  * api_key = NETUITIVE_API_KEY
  * tags = tag1:tag1val, tag2:tag2val

"""

from Handler import Handler
import logging
import re
import platform
import datetime
import time
import os
import json
import urllib2
from diamond.util import get_diamond_version

from diamond.utils.config import load_config as load_server_config

try:
    import psutil
except ImportError:
    psutil = None

try:
    import netuitive
except ImportError:
    netuitive = None

try:
    import docker
except ImportError:
    docker = None


def get_human_readable_size(num, suffix='B'):
    for unit in ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z']:
        if abs(num) < 1024.0:
            return(("%3.2f %s%s" % (num, unit, suffix)).strip())
        num /= 1024.0