On 9/4/19 12:49 PM, Carlos E. R. wrote:
On 04/09/2019 12.29, Carlos E. R. wrote:
"top" must obtain the data from somewhere. I want to obtain the same data top does, with calling another program. If there is no other way, I'll use top and parse the output.
Once (2014) I started to write a "top" equivalent, but only went as far as the header. I parsed /proc/stat, but my notes do not say where I obtained the definition of that file and I do not remember.
/proc/pid/stat output seems to be in do_task_stat() function in fs/proc/array.c. And you are looking at the utime and stime part for usermode and kernel execution time. So looks like position 14 and 15 respectfully. awk '{print $14 , "user time;", $15, "kernel time"}' stat Columns 14-17 appears to be information returned in the `man 2 times` call, the other two numbers are for child tasks. Have lots of fun, Adam -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org