mercredi 5 août 2015

Query total CPU usage of all instances of a process on Linux OS


I have a python server that forks itself once it receives a request. The python service has several C++ .so objects it can call into, as well as the python process itself.

My question is, in any one of these processes, I would like to be able to see how much CPU all instances of this server are currently using. So lets say I have foo.py, I want to see how much CPU all instances of foo.py are currently using. For example, foo.py(1) is using 200% cpu, foo.py(2) is using 300%, and foo.py(3) is using 50%, id like to arrive at 550%.

The only way I can think of doing this myself is getting the PID of every process and scanning through the /proc filesystem. Is there a more general way available within C/Python/POSIX for such an operation?

Thank you!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire