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

def get_docker_io(self, container_id, all_stats):

    io_new = {}
    try:
        iocounters = all_stats['blkio_stats']
    except KeyError as e:
        logger.debug('docker    plugin    -    Cannot    grab    block    IO    usage    for    container    {}    ({})'.format(container_id, e))
        logger.debug(all_stats)
        return io_new
    if (not hasattr(self, 'iocounters_old')):
        self.iocounters_old = {}
        try:
            self.iocounters_old[container_id] = iocounters
        except (IOError, UnboundLocalError):
            pass
    if (container_id not in self.iocounters_old):
        try:
            self.iocounters_old[container_id] = iocounters
        except (IOError, UnboundLocalError):
            pass
    else:
        try:
            ior = [i for i in iocounters['io_service_bytes_recursive'] if (i['op'] == 'Read')][0]['value']
            iow = [i for i in iocounters['io_service_bytes_recursive'] if (i['op'] == 'Write')][0]['value']
            ior_old = [i for i in self.iocounters_old[container_id]['io_service_bytes_recursive'] if (i['op'] == 'Read')][0]['value']
            iow_old = [i for i in self.iocounters_old[container_id]['io_service_bytes_recursive'] if (i['op'] == 'Write')][0]['value']
        except (IndexError, KeyError) as e:
            logger.debug('docker    plugin    -    Cannot    grab    block    IO    usage    for    container    {}    ({})'.format(container_id, e))
        else:
            io_new['time_since_update'] = getTimeSinceLastUpdate('docker_io_{}'.format(container_id))
            io_new['ior'] = (ior - ior_old)
            io_new['iow'] = (iow - iow_old)
            io_new['cumulative_ior'] = ior
            io_new['cumulative_iow'] = iow
            self.iocounters_old[container_id] = iocounters
    return io_new
