%cpu differences between sar and top

ESGLinux esggrupos at gmail.com
Wed Nov 25 12:36:41 UTC 2009


Hi again,

I have been investigating about this and I think that with top I don´t get
the usage of the cpu but I get de % of the cpu of the process.

I´ll explain better with and example.

With the command sar I get that the cpu usage es 35%, for example,
and with top I get that java is using 80% but what it is saying that the
java process is using the 80% of the 35% of the cpu usage, not the 80% of
the whole cpu.

Do you think that my conclusion is true?

BTW, is there any parameter in the system that tells the kernel the limit of
cpu a process can get?

Greetings,

ESG

2009/11/24 ESGLinux <esggrupos at gmail.com>

> Hello,
>
> I´m checking the performance of one RHEL running a java process and I use
> the sar command and the top command to see the cpu usage and I get some
> differences that I don´t understand.
>
> First I´ll tell you how I check it:
> for the sar command I run this:
> sadc -F -L 1 1000 /home/user/log/output
>
> for top I run this:
> top -b -d 1 -n 1000 -p $PID
>
> PID is the PID of my java process.
>
> Well, when I run this I get this results:
>
>               PM       CPU     %user     %nice   %system   %iowait
> %idle
> 07:09:09 PM       all     35.75             0.00      7.25      0.00
> 57.00
> 07:09:11 PM       all     50.00             0.00     13.43      0.00
> 36.57
> 07:09:13 PM       all     23.56             0.00      7.27      0.00
> 69.17
> 07:09:15 PM       all     36.75             0.00      8.00      0.00
> 55.25
> 07:09:17 PM       all     66.08             0.00     10.22      0.25
> 23.44
> 07:09:19 PM       all     31.17             0.00      6.23      0.00
> 62.59
>
> top
> TIME PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
> 19:09:09 26314 user 16 0 817m 324m 36m S 99.9 8.6 0:44.11 java
> 19:09:11 26314 user 16 0 817m 382m 36m S 99.9 10.1 0:46.70 java
> 19:09:13 26314 user 16 0 817m 381m 36m S 99.9 10.1 0:48.02 java
> 19:09:15 26314 user 16 0 828m 392m 36m S 99.9 10.4 0:49.95 java
> 19:09:18 26314 user 16 0 817m 398m 36m S 95.8 10.6 0:52.16 java
> 19:09:20 26314 user 16 0 817m 398m 36m S 51.9 10.6 0:54.20 java
>
> with sar I never reach the 99,9% of CPU but with top I see this amount of
> CPU in several times.
>
> So, which is the true value of CPU usage? and why this differences?
>
> thanks in advance
>
> ESG
>
>
>



More information about the redhat-list mailing list