Esempio n. 1
0
def get_performance_Latency(request):
    data = json.loads(request.body)
    start_time = data["timestamp"] and int(data["timestamp"]) or int(time.time())-30
    end_time = None
    latency_opts = {
         "metrics_name": "lantency",
         "timestamp_start": start_time,
         "timestamp_end": end_time,
         "correct_cnt": None,
    }
    lantency_data = vsmapi.get_metrics_all_types(request,latency_opts)
    latency_r_data = lantency_data.get('osd_op_r_latency',[])
    latency_w_data = lantency_data.get('osd_op_w_latency',[])
    latency_rw_data = lantency_data.get('osd_op_rw_latency',[])


    items = {}
    for r_metric in latency_r_data:
        items[r_metric["timestamp"]] = {"timestamp": r_metric["timestamp"], "r_value":  r_metric["metrics_value"] and round( r_metric["metrics_value"],2) or 0, "w_value": 0, "rw_value": 0}
    for w_metric in latency_w_data:
        if items.has_key(w_metric["timestamp"]):
            items[w_metric["timestamp"]]["w_value"] = w_metric["metrics_value"] and  round(w_metric["metrics_value"],2) or 0
    for rw_metric in latency_rw_data:
        if items.has_key(rw_metric["timestamp"]):
            items[rw_metric["timestamp"]]["rw_value"] = rw_metric["metrics_value"] and round(rw_metric["metrics_value"],2) or 0

    keys = items.keys()
    keys.sort()
    metric_list = [items[key] for key in keys]
    ops_data_dict = {"metrics": metric_list}
    ops_data = json.dumps(ops_data_dict)
    return ops_data
Esempio n. 2
0
def get_performance_Bandwith(request):
    data = json.loads(request.body)
    start_time = data["timestamp"] and int(data["timestamp"]) or int(time.time())-30
    end_time = None
    bandwidth_opts = {
         "metrics_name":"bandwidth"
        ,"timestamp_start":start_time
        ,"timestamp_end":end_time
        ,"correct_cnt":None
    }

    bandwidth_data = vsmapi.get_metrics_all_types(request,bandwidth_opts)
    bandwidth_in_data = bandwidth_data.get('osd_op_in_bytes',[])
    bandwidth_out_data = bandwidth_data.get('osd_op_out_bytes',[])
    items = {}
    for in_metric in bandwidth_in_data:
        items[in_metric["timestamp"]] = {"timestamp": in_metric["timestamp"], "in_value": in_metric["metrics_value"] and round(in_metric["metrics_value"],2) or 0, "out_value": 0}
    for out_metric in bandwidth_out_data:
        if items.has_key(out_metric["timestamp"]):
            items[out_metric["timestamp"]]["out_value"] = out_metric["metrics_value"] and round(out_metric["metrics_value"],2) or 0

    keys = items.keys()
    keys.sort()
    metric_list = [items[key] for key in keys]
    ops_data_dict = {"metrics": metric_list}
    ops_data = json.dumps(ops_data_dict)
    return ops_data
Esempio n. 3
0
def get_performance_IOPs(request):
    data = json.loads(request.body)
    start_time = data["timestamp"] and int(
        data["timestamp"]) or int(time.time()) - 30
    end_time = None

    ops_opts = {
        "metrics_name": "iops",
        "timestamp_start": start_time,
        "timestamp_end": end_time,
        "correct_cnt": None,
    }

    #print 'test1111'
    iops_data = vsmapi.get_metrics_all_types(request, ops_opts)
    #print 'test222'
    ops_r_data = iops_data.get('osd_op_r', [])
    ops_w_data = iops_data.get('osd_op_w', [])
    ops_rw_data = iops_data.get('osd_op_rw', [])

    items = {}
    for r_metric in ops_r_data:
        items[r_metric["timestamp"]] = {
            "timestamp": r_metric["timestamp"],
            "r_value": r_metric["metrics_value"] or 0,
            "w_value": 0,
            "rw_value": 0
        }
    for w_metric in ops_w_data:
        if items.has_key(w_metric["timestamp"]):
            items[w_metric["timestamp"]][
                "w_value"] = w_metric["metrics_value"] or 0
    for rw_metric in ops_rw_data:
        if items.has_key(rw_metric["timestamp"]):
            items[rw_metric["timestamp"]][
                "rw_value"] = rw_metric["metrics_value"] or 0

    keys = items.keys()
    keys.sort()
    metric_list = [items[key] for key in keys]

    ops_data_dict = {"metrics": metric_list}
    ops_data = json.dumps(ops_data_dict)
    return ops_data
Esempio n. 4
0
def get_performance_IOPs(request):
    data = json.loads(request.body)
    start_time = data["timestamp"] and int(data["timestamp"]) or int(time.time())-30
    end_time = None

    ops_opts = {
         "metrics_name": "iops",
         "timestamp_start": start_time,
         "timestamp_end": end_time,
         "correct_cnt": None,
    }

    #print 'test1111'
    iops_data = vsmapi.get_metrics_all_types(request,ops_opts)
    #print 'test222'
    ops_r_data = iops_data.get('osd_op_r',[])
    ops_w_data = iops_data.get('osd_op_w',[])
    ops_rw_data = iops_data.get('osd_op_rw',[])


    items = {}
    for r_metric in ops_r_data:
        items[r_metric["timestamp"]] = {"timestamp": r_metric["timestamp"], "r_value": r_metric["metrics_value"] or 0, "w_value": 0, "rw_value": 0}
    for w_metric in ops_w_data:
        if items.has_key(w_metric["timestamp"]):
            items[w_metric["timestamp"]]["w_value"] = w_metric["metrics_value"] or 0
    for rw_metric in ops_rw_data:
        if items.has_key(rw_metric["timestamp"]):
            items[rw_metric["timestamp"]]["rw_value"] = rw_metric["metrics_value"] or 0

    keys = items.keys()
    keys.sort()
    metric_list = [items[key] for key in keys]

    ops_data_dict = {"metrics": metric_list}
    ops_data = json.dumps(ops_data_dict)
    return ops_data