'Return the stats history as a JSON object (dict or None).
Limit to lasts nb items (all if nb=0)'

def get_stats_history(self, item=None, nb=0):

    s = self.get_json_history(nb=nb)
    if (item is None):
        return self._json_dumps(s)
    if isinstance(s, dict):
        try:
            return self._json_dumps({item: s[item]})
        except KeyError as e:
            logger.error('Cannot    get    item    history    {}    ({})'.format(item, e))
            return None
    elif isinstance(s, list):
        try:
            return self._json_dumps({item: map(itemgetter(item), s)})
        except (KeyError, ValueError) as e:
            logger.error('Cannot    get    item    history    {}    ({})'.format(item, e))
            return None
    else:
        return None
