Ejemplo n.º 1
0
def uptime_data():
    """Returns uptime data.
    """
    return {
        'uptime': mark(uptime.uptime(), 'duration'),
        'boottime': uptime.boottime()
    }
Ejemplo n.º 2
0
def devices_data():
    """Returns devices data.
    """
    response = {}
    for part in psutil.disk_partitions():
        device = part.device
        response[device] = {
            'device': device,
            'mountpoint': part.mountpoint,
            'fstype': part.fstype,
            'opts': part.opts,
        }
        if part.mountpoint:
            usage = psutil.disk_usage(part.mountpoint)
            response[device]['usage'] = {
                'size': mark(usage.total, 'bytes'),
                'used': mark(usage.used, 'bytes'),
                'free': mark(usage.free, 'bytes'),
                'percent': mark(usage.percent, 'percentage')
            }
    return response
Ejemplo n.º 3
0
def memory_data():
    """Returns memory data.
    """
    vm = psutil.virtual_memory()
    sw = psutil.swap_memory()

    return {
        'virtual': {
            'total': mark(vm.total, 'bytes'),
            'free': mark(vm.free, 'bytes'),
            'percent': mark(vm.percent, 'percentage')
        },
        'swap': {
            'total': mark(sw.total, 'bytes'),
            'free': mark(sw.free, 'bytes'),
            'percent': mark(sw.percent, 'percentage')
        },
    }