INNER CODE UNIT · Python

_cpu_stat

evilsocket/pwnagotchi · pwnagotchi/__init__.py:78

def _cpu_stat():
    """
    Returns the splitted first line of the /proc/stat file
    """
    with open('/proc/stat', 'rt') as fp:
        return list(map(int,fp.readline().split()[1:]))


def cpu_load():
    """
    Returns the current cpuload
    """
    parts0 = _cpu_stat()
    time.sleep(0.1)
    parts1 = _cpu_stat()
    parts_diff = [p1 - p0 for (p0, p1) in zip(parts0, parts1)]
    user, nice, sys, idle, iowait, irq, softirq, steal, _guest, _guest_nice = parts_diff
    idle_sum = idle + iowait

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…