Ejemplo n.º 1
0
def getproc(request):
    """
    Return the running processes
    """
    if not request.user.is_authenticated():
        return HttpResponseRedirect('/login')

    try:
        processes = 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
Ejemplo n.º 2
0
def cpuusage(request):
    """
    Return CPU Usage in %
    """
    if not request.user.is_authenticated():
        return HttpResponseRedirect('/login')

    try:
        cpu_usage = 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