Exemplo n.º 1
0
def getproc(request):
    """
    Return the running processes
    """
    try:
        processes = services.get_cpu_usage()
        processes = processes["all"]
    except Exception:
        processes = None

    data = json.dumps(processes)
    response = HttpResponse()
    response["Content-Type"] = "text/javascript"
    response.write(data)
    return response
Exemplo n.º 2
0
def cpuusage(request):
    """
    Return CPU Usage in %
    """
    try:
        cpu_usage = services.get_cpu_usage()

    except Exception:
        cpu_usage = 0

    cpu = [{"value": cpu_usage["free"], "color": "#0AD11B"}, {"value": cpu_usage["used"], "color": "#F7464A"}]

    data = json.dumps(cpu)
    response = HttpResponse()
    response["Content-Type"] = "text/javascript"
    response.write(data)
    return response