Ejemplo n.º 1
0
def get_disks(socketio, all_partitions=False):
    disks = []
    for disk_part in psutil.disk_partitions(all_partitions):
        usage = psutil.disk_usage(disk_part.mountpoint)
        disk = {
            'device': disk_part.device,
            'mountpoint': disk_part.mountpoint,
            'type': disk_part.fstype,
            'options': disk_part.opts,
            'space_total': bytes_fmt(usage.total),
            'space_used': bytes_fmt(usage.used),
            'space_used_percent': usage.percent,
            'space_free': bytes_fmt(usage.free)
        }
        disks.append(disk)
    return 'disks', disks
Ejemplo n.º 2
0
def get_memory(socketio):
    memory_dict = psutil.virtual_memory()._asdict()
    memory = {
        'mem_total': bytes_fmt(memory_dict['total']),
        'mem_avail': bytes_fmt(memory_dict['available']),
        'mem_percent': memory_dict['percent'],
        'mem_used': bytes_fmt(memory_dict['used']),
        'mem_free': bytes_fmt(memory_dict['free']),
        'mem_active': bytes_fmt(memory_dict['active']),
        'mem_inactive': bytes_fmt(memory_dict['inactive']),
        'mem_buffers': bytes_fmt(memory_dict['buffers']),
        'mem_cached': bytes_fmt(memory_dict['cached'])
    }
    return 'memory', memory