def compose_metric(self, request, cluster_data): metrics_cpu, metrics_mem, metrics_disk = [], [], [] for i in cluster_data['results']: time = arrow.get(i['capacity_updated_at']).timestamp * 1000 metrics_cpu.append({ 'time': time, 'remain_cpu': num_transform(i['remain_cpu']), 'total_cpu': i['total_cpu'] }) if request.project.kind == app_constants.ProjectKind.MESOS.value: # transfer GB total_mem = normalize_metric(i['total_mem'] / 1024) remain_mem = normalize_metric( num_transform(i['remain_mem']) / 1024) else: total_mem = normalize_metric(i['total_mem']) remain_mem = normalize_metric(num_transform(i['remain_mem'])) metrics_mem.append({ 'time': time, 'remain_mem': remain_mem, 'total_mem': total_mem }) # add disk metric metrics_disk.append({ 'time': time, 'remain_disk': normalize_metric(num_transform(i['remain_disk']) / 1024), 'total_disk': normalize_metric(i['total_disk'] / 1024) }) return metrics_cpu, metrics_mem, metrics_disk
def compose_metric(self, request, cluster_data): metrics_cpu, metrics_mem, metrics_disk = [], [], [] for i in cluster_data['results']: time = arrow.get(i['capacity_updated_at']).timestamp * 1000 metrics_cpu.append({ 'time': time, 'remain_cpu': num_transform(i['remain_cpu']), 'total_cpu': i['total_cpu'] }) total_mem = normalize_metric(i['total_mem']) remain_mem = normalize_metric(num_transform(i['remain_mem'])) metrics_mem.append({ 'time': time, 'remain_mem': remain_mem, 'total_mem': total_mem }) # add disk metric metrics_disk.append({ 'time': time, 'remain_disk': normalize_metric(num_transform(i['remain_disk']) / 1024), 'total_disk': normalize_metric(i['total_disk'] / 1024), }) return metrics_cpu, metrics_mem, metrics_disk