sandbox/utils.py
def usage():
    """Return the dictionary corresponding to the /usage/ API endpoints."""
    
    io_usage, network_usage = usage_io_network()
    
    return {
        "cpu":       {
            "frequency": psutil.cpu_freq()[0],
            "usage":     psutil.cpu_percent() / 100,
            "usage_avg": [x / psutil.cpu_count() for x in psutil.getloadavg()]
        },
        "memory":    {
            "ram":     psutil.virtual_memory()[3],
            "swap":    psutil.swap_memory()[1],
            "storage": {
                p[0]: psutil.disk_usage(p[1])[1] for p in psutil.disk_partitions()
            }
        },
        "io":        io_usage,
        "network":   network_usage,
        "process":   len(psutil.pids()),
        "container": settings.DOCKER_COUNT - Sandbox.available(),
    }
Return the dictionary corresponding to the /usage/ API endpoints.
Return the dictionary corresponding to the /usage/ API endpoints.
Return the dictionary corresponding to the / usage / API endpoints .
def usage():
    io_usage, network_usage = usage_io_network()
    return {
        "cpu":       {
            "frequency": psutil.cpu_freq()[0],
            "usage":     psutil.cpu_percent() / 100,
            "usage_avg": [x / psutil.cpu_count() for x in psutil.getloadavg()]
        },
        "memory":    {
            "ram":     psutil.virtual_memory()[3],
            "swap":    psutil.swap_memory()[1],
            "storage": {
                p[0]: psutil.disk_usage(p[1])[1] for p in psutil.disk_partitions()
            }
        },
        "io":        io_usage,
        "network":   network_usage,
        "process":   len(psutil.pids()),
        "container": settings.DOCKER_COUNT - Sandbox.available(),
    }
def usage ( ) : io_usage , network_usage = usage_io_network ( ) return { "cpu" : { "frequency" : psutil . cpu_freq ( ) [ 0 ] , "usage" : psutil . cpu_percent ( ) / 100 , "usage_avg" : [ x / psutil . cpu_count ( ) for x in psutil . getloadavg ( ) ] } , "memory" : { "ram" : psutil . virtual_memory ( ) [ 3 ] , "swap" : psutil . swap_memory ( ) [ 1 ] , "storage" : { p [ 0 ] : psutil . disk_usage ( p [ 1 ] ) [ 1 ] for p in psutil . disk_partitions ( ) } } , "io" : io_usage , "network" : network_usage , "process" : len ( psutil . pids ( ) ) , "container" : settings . DOCKER_COUNT - Sandbox . available ( ) , }
Return the dictionary corresponding to the /usage/ API endpoints.
Return the dictionary corresponding to the / usage / API endpoints .
"""Return the dictionary corresponding to the /usage/ API endpoints."""