#!/usr/bin/env python3 import psutil, os, sys, time t=time.clock_gettime(time.CLOCK_MONOTONIC) for p in psutil.process_iter(): try: with p.oneshot(): print(p.pid,p.username(),p.name(),p.memory_info().rss,p.cpu_times()) except Exception as e: pass t=time.clock_gettime(time.CLOCK_MONOTONIC)-t print(t,file=sys.stderr)