Exemple #1
0
def _get_memory():
    memory = psutil.virtual_memory()
    return (
        humanize_bytes(memory.used),
        humanize_bytes(memory.total),
        colorize_percent(memory.percent, warning=60, critical=80),
    )
Exemple #2
0
def _get_disks():
    result = []
    for disk in psutil.disk_partitions(all=False):
        if psutil.WINDOWS and ("cdrom" in disk.opts or disk.fstype == ""):
            # skip cd-rom drives with no disk in it on Windows; they may raise
            # ENOENT, pop-up a Windows GUI error for a non-ready partition or
            # just hang
            continue

        usage = psutil.disk_usage(disk.mountpoint)
        result.append(
            (
                disk.mountpoint,
                humanize_bytes(usage.used),
                humanize_bytes(usage.total),
                colorize_percent(usage.percent, warning=70, critical=85),
            )
        )
    return result