python process accounting

Giampaolo Rodola' g.rodola at gmail.com
Tue Apr 30 13:18:56 EDT 2013


2013/4/30 Rita <rmorgan466 at gmail.com>:
> Hi,
>
> I was wondering if it possible to write a python wrapper which will account
> my processes. I would like to account for all the children processes (fork)
> by looking at their /proc/<pid> info. Such as memory, io, open files, stats.
>
> So, instead of me running "/bin/sleep 10", i would like to run it as
> "pywrap.py /bin/sleep 10" and it will do an exec /bin/sleep 10 and do a
> periodic snapshot for whats in /proc/<pid>/stats.
>
>
>
>
> --
> --- Get your facts first, then you can distort them as you please.--
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Not sure what you're talking about expect for the process management
part in which case it seems you're looking for psutil:
https://code.google.com/p/psutil/#Process_management
In detail, if you want to work with process children:

>>> import psutil, os
>>> thisproc = psutil.Process(os.getpid())
>>> for child in thisproc.get_children():
...          print child.name
...          print child.get_memory_info()
...          print child.get_open_files()
...

--- Giampaolo
https://code.google.com/p/pyftpdlib/
https://code.google.com/p/psutil/
https://code.google.com/p/pysendfile/



More information about the Python-list mailing list