예제 #1
0
    def get_prom_data(self, data):
        _data = []
        if data['metric'] == 'disk':
            metric_data = prometheus.get_container_diskio_usage(
                data['res_id'], data['start_at'], data['end_at'])
            if metric_data:
                _data = {'list': [{'device_name': '', 'metrics': metric_data}]}

        elif data['metric'] == 'cpu_summary':
            metric_data = prometheus.get_container_cpu_usage(
                data['res_id'], data['start_at'], data['end_at'])
            if metric_data:
                _data = {'list': metric_data}

        elif data['metric'] == 'net':
            metric_data = prometheus.get_container_network_usage(
                data['res_id'], data['start_at'], data['end_at'])
            if metric_data:
                _data = {'list': [{'device_name': '', 'metrics': metric_data}]}

        elif data['metric'] == 'mem':
            metric_data = prometheus.get_container_memory_usage(
                data['res_id'], data['start_at'], data['end_at'])
            if metric_data:
                _data = {'list': metric_data}
        return _data
예제 #2
0
    def get_multi_prom_data(self, data):
        _data = []

        if data['metric'] == 'cpu_summary':
            metric_data = prometheus.get_container_cpu_usage(data['res_id_list'], data['start_at'], data['end_at'])
            if metric_data:
                _data = {'list': metric_data}

        elif data['metric'] == 'mem':
            metric_data = prometheus.get_container_memory_usage(data['res_id_list'], data['start_at'], data['end_at'])
            if metric_data:
                _data = {'list': metric_data}

        return _data