LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   CPU consumption - %usr and %sys ?? (https://www.linuxquestions.org/questions/linux-general-1/cpu-consumption-usr-and-sys-799520/)

gomes1333 04-02-2010 01:17 AM

CPU consumption - %usr and %sys ??
 
On Linux, top shows how much % of CPU is consumed by "user" as well as "sys" like below.


Tasks: 272 total, 3 running, 268 sleeping, 0 stopped, 1 zombie
Cpu(s): 65.9%us, 33.8%sy, 0.0%ni, 0.2%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 16300960k total, 16212488k used, 88472k free, 9508k buffers
Swap: 33554424k total, 5112656k used, 28441768k free, 3502720k cached


In above example I see that there is 33.8% consumed by "sys". How do I find which process(es) is/are contributing to the "sys" cpu consumption?

Mr-Bisquit 04-02-2010 01:36 AM

Eliminate the processes by user such as Desktop environment, networking that is controlled, open apps.
Open two terminals and line them side by side.
In one type top and in the other
Code:

ps -U <your username>
. That will make it easier.

gomes1333 04-02-2010 02:12 AM

i can get the cpu utilization of a process.. how do i know how much of it is consumed as "sys" and "user"?

The ps doesn't help in that case.

syg00 04-02-2010 03:54 AM

You can't. Once you're in kernel context you're no longer a (userspace) "process".

gomes1333 04-02-2010 04:06 AM

So, I guess there is no way I can find what is consuming the %sys CPU

Mr-Bisquit 04-02-2010 12:41 PM

Follow the directions.
Open two terminals again
Left terminal
Code:

top -U <your username>
; right terminal
Code:

ps -U <your username>
.
I'm currently using OpenBSD;but, these commands will work on both Linux/GNU and BSD with the same results.

You will see a difference in the output and know what processes are user.

gomes1333 04-03-2010 05:13 AM

Here is what I see on my RH Linux.. and this doesn't help.

----

=> ps -U userid
PID TTY TIME CMD
10000 ? 00:00:01 perl
23703 pts/1 00:00:00 ksh
23885 ? 00:00:00 sshd
23886 pts/4 00:00:00 ksh
23979 pts/4 00:00:00 ps
32283 ? 00:00:00 startWebLogic.s
32328 ? 1-15:23:04 java

----
=> top -U userid
top - 03:10:28 up 32 days, 18:24, 4 users, load average: 2.33, 2.39, 2.44
Tasks: 272 total, 1 running, 271 sleeping, 0 stopped, 0 zombie
Cpu(s): 17.6%us, 8.8%sy, 0.0%ni, 73.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 16300960k total, 16205404k used, 95556k free, 269200k buffers
Swap: 33554424k total, 3099020k used, 30455404k free, 3480636k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
32328 userid 16 0 4047m 2.5g 232m S 100.9 16.2 2369:23 java
24007 userid 15 0 12880 1260 832 R 0.7 0.0 0:01.33 top
10000 userid 18 0 26516 3704 1628 S 0.0 0.0 0:01.42 perl
23703 userid 16 0 65432 2180 1196 S 0.0 0.0 0:00.03 ksh
23885 userid 15 0 91312 2328 1036 S 0.0 0.0 0:00.00 sshd
23886 userid 15 0 65432 2188 1196 S 0.0 0.0 0:00.00 ksh
32283 userid 20 0 63968 1016 1012 S 0.0 0.0 0:00.01 startWebLogic.s


All times are GMT -5. The time now is 05:25 PM.