Exemplo n.º 1
0
def list_metric():
    apikey = request.args.get("apikey")
    secret = request.args.get("secret")
    owner = request.args.get("owner")
    ucloud_client = Client(api_type="watch", api_key=apikey, secret=secret, owner=owner)
    parser = Parse()
    response = ucloud_client.request("listMetrics")
    dump_result = json.dumps(response)
    parsed_result = parser.parse(dump_result)
    return "%s" % parsed_result
Exemplo n.º 2
0
def get_metric_data():
    apikey = request.args.get("apikey")
    secret = request.args.get("secret")
    owner = request.args.get("owner")
    input_args = dict()
    input_args["namespace"] = request.args.get("namespace")
    dimension_name = request.args.get("dimension_name")
    dimension_value = request.args.get("dimension_value")
    print "dimension_name = %s" % (dimension_name)
    print "dimension_value = %s" % (dimension_value)
    if dimension_name != "no dimension":
        input_args["dimensions.member.1.name"] = dimension_name
    if dimension_value != "no dimension":
        input_args["dimensions.member.1.value"] = dimension_value
    input_args["metricname"] = request.args.get("metricname")
    input_args["starttime"] = request.args.get("starttime")
    input_args["endtime"] = request.args.get("endtime")
    input_args["period"] = "5"
    input_args["statistics.member.1"] = "Maximum"
    input_args["statistics.member.2"] = "Minimum"
    input_args["statistics.member.3"] = "Average"
    input_args["statistics.member.4"] = "Sum"
    input_args["statistics.member.5"] = "SampleCount"
    if (
        input_args["metricname"] == "CPUUtilization"
        or input_args["metricname"] == "load_avg1"
        or input_args["metricname"] == "CPUIoWait"
        or input_args["metricname"] == "CPULoadAverage"
    ):
        input_args["unit"] = "Percent"
    else:
        input_args["unit"] = "Bytes"
    ucloud_client = Client(api_type="watch", api_key=apikey, secret=secret, owner=owner)
    response = ucloud_client.request(command="getMetricStatistics", input_args=input_args)
    dump_result = json.dumps(response)
    return "%s" % dump_result
Exemplo n.º 3
0
def test(apikey, secret, owner):
    print "apikey = %s, scret = %s, owner = %s" % (apikey, secret, owner)
    ucloud_client = Client(api_type="watch", api_key=apikey, secret=secret, owner=owner)
    response = ucloud_client.request("listMetrics")
    dump_result = json.dumps(response)
    return "%s" % dump_result