def perfdata( metric_id, timewindow=None, period=None, with_meta=True, limit=0, skip=0, timeserie=None, meta=None, sliding_time=False ): if timewindow is not None: timewindow = TimeWindow(**timewindow) if timeserie is not None: if period is None: period = timeserie.pop('period', None) timeserie = TimeSerie(**timeserie) if period is not None: timeserie.period = Period(**period) if not isinstance(metric_id, list): metrics = [metric_id] else: metrics = metric_id result = [] for metric_id in metrics: # meta -> _meta pts, _meta = manager.get( metric_id=metric_id, with_meta=True, timewindow=timewindow, limit=limit, skip=skip, meta=meta, sliding_time=sliding_time ) _meta['data_id'] = metric_id if timeserie is not None: pts = timeserie.calculate(pts, timewindow, meta=_meta) if with_meta: result.append({ 'points': pts, 'meta': _meta }) else: result.append({ 'points': pts }) return (result, len(result))
def get(self, metric_id, timewindow=None, period=None, with_meta=True, limit=0, skip=0, timeserie=None): if timewindow is not None: timewindow = TimeWindow(**timewindow) if timeserie is not None: if period is None: period = timeserie.pop("period", None) timeserie = TimeSerie(**timeserie) if period is not None: timeserie.period = Period(**period) if not isinstance(metric_id, list): metrics = [metric_id] else: metrics = metric_id result = [] for metric_id in metrics: pts, meta = self.manager.get( metric_id=metric_id, with_meta=True, timewindow=timewindow, limit=limit, skip=skip ) meta = meta[0] if timeserie is not None: pts = timeserie.calculate(pts, timewindow, meta=meta) if with_meta: result.append({"points": pts, "meta": meta}) else: result.append({"points": pts}) return (result, len(result))
def perfdata(metric_id, timewindow=None, period=None, with_meta=True, limit=0, skip=0, timeserie=None): if timewindow is not None: timewindow = TimeWindow(**timewindow) if timeserie is not None: if period is None: period = timeserie.pop("period", None) timeserie = TimeSerie(**timeserie) if period is not None: timeserie.period = Period(**period) if not isinstance(metric_id, list): metrics = [metric_id] else: metrics = metric_id result = [] for metric_id in metrics: # meta -> _meta pts, _meta = manager.get(metric_id=metric_id, with_meta=True, timewindow=timewindow, limit=limit, skip=skip) meta = _meta[0] if _meta is not None else {} meta[manager[PerfData.META_STORAGE].DATA_ID] = metric_id if timeserie is not None: pts = timeserie.calculate(pts, timewindow, meta=meta) if with_meta: result.append({"points": pts, "meta": meta}) else: result.append({"points": pts}) return (result, len(result))