I have a process which on a timely interval need to retrieve the CPU Usage of other processes on the machine, I need to get the actual Cpu Time, and not % of the Cpu used. (similiar to clock_gettime / getrusage)
Those processes may change the PID during the run time of the main process
using "top" or "ps" only results in cpu usage by %, and as far as i know (if i am wrong - please tell me, would make it much easier) cant be modified to show actual cpu usage in seconds.
The solution i thought of is using ps to actually get the processes PIDS (i only have names) , then accessing each one of those processes /proc/pid/stat and retrieving the necessary information (utime/stime).
I was hoping there is some other possible solution, which i am missing.
Thank you
Aucun commentaire:
Enregistrer un commentaire