예제 #1
0
파일: tables.py 프로젝트: amanjain91/Netmon
def get_mem_utilization_snapshot(instance, back=60):
    mem_files = utils.get_whisper_files_by_metric(
                "mem",
                utils.get_whisper_files_by_instance_id(instance.id))

    if not mem_files:
        return "N/A"

    fetched = whisper.fetch(mem_files[0], time.time() - back)
    times, data = fetched

    for val in reversed(data):
        if val is not None:
            return val * 100

    return "N/A"
예제 #2
0
파일: tables.py 프로젝트: amanjain91/Netmon
def get_cpu_utilization_snapshot(instance, back=60):
    cpu_files = utils.get_whisper_files_by_metric(
                "cpu",
                utils.get_whisper_files_by_instance_id(instance.id))
    
    if not cpu_files:
        return "N/A"

    # TODO: what if we have more than one CPU database??
    fetched = whisper.fetch(cpu_files[0], time.time() - back)
    times, data = fetched

    # return the most recent data point that's not None
    for val in reversed(data):
        if val is not None:
            return val * 100

    return "N/A"
예제 #3
0
파일: tables.py 프로젝트: amanjain91/Netmon
def get_vcpu_load_avgs(instance):
    cpu_files = utils.get_whisper_files_by_metric(
                "cpu",
                utils.get_whisper_files_by_instance_id(instance.id))

    if not cpu_files:
        return "N/A"

    # TODO: what if we have more than one CPU database??
    f = cpu_files[0]
    avgs = []

    for duration in [1, 5, 15]:
        fetched = whisper.fetch(f, time.time() - 60*duration)
        times, data = fetched
        load_avg = utils.average(data)
        avgs.append(load_avg)

    return "%f | %f | %f" % tuple(avgs)