'Return the container network usage using the Docker API (v1.0 or higher).
Input: id is the full container id
Output: a dict {\'time_since_update\': 3000, \'rx\': 10, \'tx\': 65}.
with:
time_since_update: number of seconds elapsed between the latest grab
rx: Number of byte received
tx: Number of byte transmited'

def get_docker_network(self, container_id, all_stats):

    network_new = {}
    try:
        netcounters = all_stats['networks']
    except KeyError as e:
        logger.debug('docker    plugin    -    Cannot    grab    NET    usage    for    container    {}    ({})'.format(container_id, e))
        logger.debug(all_stats)
        return network_new
    if (not hasattr(self, 'inetcounters_old')):
        self.netcounters_old = {}
        try:
            self.netcounters_old[container_id] = netcounters
        except (IOError, UnboundLocalError):
            pass
    if (container_id not in self.netcounters_old):
        try:
            self.netcounters_old[container_id] = netcounters
        except (IOError, UnboundLocalError):
            pass
    else:
        try:
            network_new['time_since_update'] = getTimeSinceLastUpdate('docker_net_{}'.format(container_id))
            network_new['rx'] = (netcounters['eth0']['rx_bytes'] - self.netcounters_old[container_id]['eth0']['rx_bytes'])
            network_new['tx'] = (netcounters['eth0']['tx_bytes'] - self.netcounters_old[container_id]['eth0']['tx_bytes'])
            network_new['cumulative_rx'] = netcounters['eth0']['rx_bytes']
            network_new['cumulative_tx'] = netcounters['eth0']['tx_bytes']
        except KeyError as e:
            logger.debug('docker    plugin    -    Cannot    grab    network    interface    usage    for    container    {}    ({})'.format(container_id, e))
            logger.debug(all_stats)
        self.netcounters_old[container_id] = netcounters
    return network_new
