SaltyCrane Blog — Notes on JavaScript and web development

psutil example

$ pip install psutil

import psutil

def main2():
    pid = os.getpid()
    print pid
    p = psutil.Process(pid)
    print p.name
    print p.exe
    print p.status
    print p.username
    print p.create_time
    print p.terminal
    print p.uids
    print p.gids
    print p.get_cpu_percent(interval=1.0)
    print p.get_memory_percent()
    print p.get_memory_info()
    print p.get_cpu_times()
    print p.get_io_counters()
    print p.get_open_files()
    print p.get_connections()
    print p.get_threads()
    print p.nice
    p.suspend()
    p.resume()
    p.terminate()
    print 'asfd'

Comments