免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2429 | 回复: 0
打印 上一主题 下一主题

How do I Find Out Linux CPU Utilization [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-08-27 09:59 |只看该作者 |倒序浏览

How do I Find Out Linux CPU Utilization?

Whenever a Linux system CPU is occupied by a process, it is unavailable for processing other requests. Rest of pending requests must wait till CPU is free. This becomes a bottleneck in the system. Following command will help you to identify CPU utilization, so that you can troubleshoot CPU related performance problems.
Finding CPU utilization is one of the important tasks. Linux comes with various utilities to report CPU utilization. With these commands, you will be able to find out:
* CPU utilization
* Display the utilization of each CPU individually (SMP cpu)
* Find out your system's average CPU utilization since the last reboot etc
* Determine which process is eating the CPU(s)
Old good top command to find out Linux cpu load
The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel.
The top command monitors CPU utilization, process statistics, and memory utilization. The top section contains information related to overall system status - uptime, load average, process counts, CPU status, and utilization statistics for both memory and swap space.
Top command to find out Linux cpu usage
Type the top command:
$ top
Output:

You can see Linux CPU utilization under CPU stats. The task’s share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. In a true SMP environment (multiple CPUS), top will operate in number of CPUs. Please note that you need to type q key to exit the top command display.
The top command produces a frequently-updated list of processes. By default, the processes are ordered by percentage of CPU usage, with only the "top" CPU consumers shown. The top command shows how much processing power and memory are being used, as well as other information about the running processes.
Find Linux CPU utilization using mpstat and other tools
Please note that you need to install special package called sysstat to take advantage of following commands. This package includes system performance tools for Linux (Red Hat Linux / RHEL includes these tools by default).
# apt-get install sysstat
Use up2date command if you are using RHEL:
# up2date sysstat
Display the utilization of each CPU individually using mpstat
If you are using SMP (Multiple CPU) system, use mpstat command to display the utilization of each CPU individually. It report processors related statistics. For example, type command:
# mpstat Output:
Linux 2.6.15.4 (debian)         Thursday 06 April 2006
05:13:05  IST  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s
05:13:05  IST  all   16.52    0.00    2.87    1.09    0.07    0.02    0.00   79.42    830.06
The mpstat command display activities for each available processor, processor 0 being the first one. Global average activities among all processors are also reported. The mpstat command can be used both on SMP and UP machines, but in the latter, only global average activities will be printed.:
# mpstat -P ALL
Output:
Linux 2.6.15.4 (wwwportal1.xxxx.co.in)         Thursday 06 April 2006
05:14:58  IST  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s
05:14:58  IST  all   16.46    0.00    2.88    1.08    0.07    0.02    0.00   79.48    835.96
05:14:58  IST    0   16.46    0.00    2.88    1.08    0.07    0.02    0.00   79.48    835.96
05:14:58  IST    1   15.77    2.70    3.17    2.01    0.05    0.03    0.00   81.44    822.54
Another output from my HP Dual Opteron 64 bit server:# mpstat -P ALLOutput:
Linux 2.6.5-7.252-smp (ora9.xxx.in)   04/07/06
07:44:18     CPU   %user   %nice %system %iowait    %irq   %soft   %idle    intr/s
07:44:18     all    3.01   57.31    0.36    0.13    0.01    0.00   39.19   1063.46
07:44:18       0    5.87   69.47    0.44    0.05    0.01    0.01   24.16    262.11
07:44:18       1    1.79   48.59    0.36    0.23    0.00    0.00   49.02    268.92
07:44:18       2    2.19   42.63    0.28    0.16    0.01    0.00   54.73    260.96
07:44:18       3    2.17   68.56    0.34    0.06    0.03    0.00   28.83    271.47
Report CPU utilization using sar command
You can display today’s CPU activity, with sar command:
# sar
Output:
Linux 2.6.9-42.0.3.ELsmp (dellbox.xyz.co.in)         01/13/2007
12:00:02 AM       CPU     %user     %nice   %system   %iowait     %idle
12:10:01 AM       all      1.05      0.00      0.28      0.04     98.64
12:20:01 AM       all      0.74      0.00      0.34      0.38     98.54
12:30:02 AM       all      1.09      0.00      0.28      0.10     98.53
12:40:01 AM       all      0.76      0.00      0.21      0.03     99.00
12:50:01 AM       all      1.25      0.00      0.32      0.03     98.40
01:00:01 AM       all      0.80      0.00      0.24      0.03     98.92
...
.....
..
04:40:01 AM       all      8.39      0.00     33.17      0.06     58.38
04:50:01 AM       all      8.68      0.00     37.51      0.04     53.78
05:00:01 AM       all      7.10      0.00     30.48      0.04     62.39
05:10:01 AM       all      8.78      0.00     37.74      0.03     53.44
05:20:02 AM       all      8.30      0.00     35.45      0.06     56.18
Average:          all      3.09      0.00      9.14      0.09     87.68
Comparison of CPU utilization
The sar command writes to standard output the contents of selected cumulative activity counters in the operating system. The accounting system, based on the values in the count and interval parameters. For example display comparison of CPU utilization; 2 seconds apart; 5 times, use:
# sar -u 2 5
Output (for each 2 seconds. 5 lines are displayed):
Linux 2.6.9-42.0.3.ELsmp (www1lab2.xyz.ac.in)         01/13/2007
05:33:24 AM       CPU     %user     %nice   %system   %iowait     %idle
05:33:26 AM       all      9.50      0.00     49.00      0.00     41.50
05:33:28 AM       all     16.79      0.00     74.69      0.00      8.52
05:33:30 AM       all     17.21      0.00     80.30      0.00      2.49
05:33:32 AM       all     16.75      0.00     81.00      0.00      2.25
05:33:34 AM       all     14.29      0.00     72.43      0.00     13.28
Average:          all     14.91      0.00     71.49      0.00     13.61
Where,

  • -u 12 5 : Report CPU utilization. The following values are displayed:

    • %user: Percentage of CPU utilization that occurred while executing at the user level (application).
    • %nice: Percentage of CPU utilization that occurred while executing at the user level with nice priority.
    • %system: Percentage of CPU utilization that occurred while executing at the system level (kernel).
    • %iowait: Percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.
    • %idle: Percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request.

To get multiple samples and multiple reports set an output file for the sar command. Run the sar command as a background process using.
# sar -o output.file 12 8 >/dev/null 2>&1 &
Better use nohup command so that you can logout and check back report later on:
# nohup sar -o output.file 12 8 >/dev/null 2>&1 &
All data is captured in binary form and saved to a file (data.file). The data can then be selectively displayed ith the sar command using the -f option.
# sar -f data.file
Task: Find out who is monopolizing or eating the CPUs
Finally, you need to determine which process is monopolizing or eating the CPUs. Following command will displays the top 10 CPU users on the Linux system.
# ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10
OR
# ps -eo pcpu,pid,user,args | sort -r -k1 | less
Output:
%CPU   PID USER     COMMAND
  96  2148 vivek    /usr/lib/vmware/bin/vmware-vmx -C /var/lib/vmware/Virtual Machines/Ubuntu 64-bit/Ubuntu 64-bit.vmx -@ ""
0.7  3358 mysql    /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --socket=/var/lib/mysql/mysql.sock
0.4 29129 lighttpd /usr/bin/php
0.4 29128 lighttpd /usr/bin/php
0.4 29127 lighttpd /usr/bin/php
0.4 29126 lighttpd /usr/bin/php
0.2  2177 vivek    [vmware-rtc]
0.0     9 root     [kacpid]
0.0     8 root     [khelper]
Now you know vmware-vmx process is eating up lots of CPU power. ps command displays every process (-e) with a user-defined format (-o pcpu). First field is pcpu (cpu utilization). It is sorted in reverse order to display top 10 CPU eating process.
iostat command
You can also use iostat command which report Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions. It can be use to find out your system's average CPU utilization since the last reboot.
# iostatOutput:
Linux 2.6.15.4 (debian)         Thursday 06 April 2006
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
     16.36    0.00    2.99    1.06    0.00   79.59
Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
hda               0.00         0.00         0.00         16          0
hdb               6.43        85.57       166.74     875340    1705664
hdc               0.03         0.16         0.00       1644          0
sda               0.00         0.00         0.00         24          0
You may want to use following command, which gives you three outputs every 5 seconds (as previous command gives information since the last reboot):$ iostat -xtc 5 3
GUI tools for your laptops/desktops
Above tools/commands are quite useful on remote server. For local system with X GUI installed you can try out gnome-system-monitor. It allows you to view and control the processes running on your system. You can access detailed memory maps, send signals, and terminate the processes.
$ gnome-system-monitor

(Click to enlarge image)
In addition, the gnome-system-monitor provides an overall view of the resource usage on your system, including memory and CPU allocation.

(Click to enlarge image)
Further readings

  • For more information and command option please read man pages of top, iostat, mpstat, sar, ps commands.

                       
-->
Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our
weekly newsletter here
!

Email this to a friend
Printable version
Rss Feed
Last Updated: Dec/18/2008
{ 1 trackback }
My Mind … » Blog Archive » Linux Commands to check CPU/Memory utilization
12.04.08 at 10:14 am
{ 89 comments… read them below or
add one
}


1
Yuchi 04.07.06 at 12:48 pm
Sounds interesting


2
Anonymous 04.07.06 at 1:05 pm
Never knew the mpstat command. Thanks for post. You got kick ass info :D


3
Anonymous 07.27.06 at 7:09 pm
So you have 4 processors shown on your dual opteron machine which means that 2 of them are virtual. How do youfilter these out when you want to see only raw info on real processor utilization?
Thanks
Nikola


4
Anonymous 07.27.06 at 7:14 pm
I need to explain better i think:
so i have 4 processors and what if only 2 are working and i still see 4 because of additional virtual processors? How do i check that? Plz answer its really important to me.
Thanks in advance,
Nikola


5
nixcraft 07.28.06 at 4:40 am
If cpu entry not present in /proc/interrupts file your cpu is offline or not working for some causes:
less /proc/interrupts
You can also goto directory /sys/devices/system/cpu (note following commands needs special configuration option via kernel. If it is not complied it will not work for you):
cd /sys/devices/system/cpu
Type ls command to see all cpus
ls
Output:
cpu0 cpu1 cpu2 cpu3 cpu4 cpu5 cpu6 cpu7
Inside this directory you will see entry for online or offline CPU
Hope this helps


6
Ashok 11.07.06 at 10:11 pm
Thanks for the commands – i really could use the iostat command and get some answers.. Thanks Again !! :)


7
nixcraft 11.08.06 at 8:58 am
Ashok,
I am glad – commands and help presented here helping out.
Appreciate your post.


8
chadi 12.29.06 at 9:18 am
hi all i have a prob i use top and i have mysql has a %cpu 99.5 and i use mpstat but i have not the same results why with us and sy and ni
i have smp linux rehl3


9
nixcraft 12.29.06 at 10:47 am
MySQL is generally use more disk i/o; use iostat to get detailed information. You need to optimize mysql and also get fast SCSI hard disk.


10
Planet Malaysia 01.15.07 at 5:38 am
Yeah! Now I know new command “mpstat”


11
Pádraig Brady 01.15.07 at 9:59 am
This is the command I use to see who’s using CPU:
ps -e -o pcpu,cpu,nice,state,cputime,args –sort pcpu | sed ‘/^ 0.0 /d’
That and more here:
http://www.pixelbeat.org/cmdline.html#monitor


12
nixcraft 01.15.07 at 11:35 am
Pádraig,
Good syntax, just to list top 10, sorting should be -pcpu and pipe to head -10
ps -e -o pcpu,cpu,nice,state,cputime,args –sort -pcpu | sed ‘/^ 0.0 /d’ | head -10
Appreciate your post.


13
Markus Sorensson 01.15.07 at 1:23 pm
Ok, I can measure the cpu utilization… but what is the criteria to determine when a cpu is overloaded? Please let me know!


14
SpongeMucker 01.15.07 at 2:13 pm
Good Article. However, you neglected to mention vmstat. One of the nice things about vmstat is that it provides an insight into how the queues are filling up on each processor. Also, vmstat comes with just about every default install of UNIX and Linux that I have ever seen, so there are no additional files which need to be installed. vmstat is also very scriptable, if you need to log the cpu usage at intervals of time. Hope that this helps. Thanks again for a good article.


15
jon 01.15.07 at 4:35 pm
Just FYI – on fedora machines, you’ll need to:
$ yum install sysstat
To install the sysstat package which contains (most of) the binaries listed in this article.


16
nixcraft 01.15.07 at 8:08 pm
@Markus when you see CPU load >=70%
@SpongeMucker: yup vmstat is good tool =>
http://www.cyberciti.biz/tips/linux-resource-utilization-to-detect-system-bottlenecks.html
. I will update post with vmstat link.
@ jon : thanks for pointing out fedora core issue.
Appreciate all of your posts.


17
JM 01.15.07 at 10:06 pm
htop works great for me. It’s a little easier on the eyes than regular old top.


18
Santiago 01.21.07 at 3:28 am
You can use the “atop” utility(Monitor for system resources and process activity)


19
nixcraft 01.22.07 at 3:26 pm
Santiago/jm
Yup, atop/htop is also useful.
Appreciate your posts.


20
drown 02.01.07 at 4:35 am
yes its very good explaination..
but how can one get this information like cpu usage into a program.. say C code?..
say i wanted cpu usage into my float variable..
please help.. thnks in advance…


21
nixcraft 02.01.07 at 10:08 pm
Drown,
I am not sure about C API.


22
blackice 02.05.07 at 10:29 pm
@19. nixcraft
Thanks, htop worked great for debian sarge, mpstat didn’t worked very well.


23
Puneet 04.16.07 at 10:06 am
Thanks man…helped a lot..:)
~Puneet


24
Vishal 06.06.07 at 5:58 am
Thanks a lot it is really helpful.!!


25
Diptanjan 06.12.07 at 6:10 am
This is really a wonderful article…
Learned a lot from this… And thank you all the readers for posting valuable comments with different commands.. this is really helpful for people like me.
Diptanjan


26
Ramanath 06.29.07 at 12:13 pm
This is a nice and informative article.
Can anyone suggest any command to monitor a process is using which cpu in SMP environment. I mean suppose I am running sshd. How do I know it is using cpu0 or cpu1 ?


27
benny 07.06.07 at 6:42 pm
Thanks a lot for the post. Its really helpful.


28
MG 07.18.07 at 1:39 am
very good information…it would be good if we can have at least some hints on whether the stats shown is still ok or need to check on other items


29
colbert 08.24.07 at 5:35 am
thanks for the tips. its good read for my day to day job


30
invisible 09.13.07 at 6:00 am
Really good article.
I have a following question – what is the best way to find out which process(es) was(were) using cpu(s) for certain period of time based on cpu utilization threshold?
Let’s imagine that we want to find all processes triggering CPU utilization beyond 70% for more then 10 seconds during last 24 hours and dump such an information in a log with the snapshots of time of occurrence, process ID and command.
Anyone has an idea how to setup such a monitoring in an elegant way?
Thanks,
–invisible


31
laga 10.02.07 at 4:08 pm
Thanks for the mpstat command!


32
zhili wang 10.08.07 at 4:05 am
One of our server has four CPUs, but when I use mpstat or top, I can only see one CPU. In the directory /sys/devices/system/cpu, only show cpu0. But we do have 4 cpu, and OS admin told me all four cpu are runing. How do I know all four cpus are runing properly and I can use it.
Thanks for any help.


33
vivek 10.08.07 at 7:58 am
zhili,
Install SMP Linux kernel RPM / package and reboot the box. Run top or cat /proc/cpuinfo command to confirm CPU count


34
zhili wang 10.08.07 at 6:13 pm
my server has four CPUs, but when I issue vmstat and top, I can only see one cpu. In the directory:/sys/devices/system/cpu, I can see only one cpu – cpu0. When I issue command:less /proc/interrupts, it only show one cpu. But there are do have four cpu on the server, should I do something to configure it, what should I do.
Thanks for any help.


35
zhili wang 10.08.07 at 6:16 pm
Vivek,
Thank you for your help, I will let Linux Admin here do it.


36
vivek 10.08.07 at 7:21 pm
>should I do something to configure it, what should I do
Yup, ask your admin to install Linux SMP kernel and boot into the same using Grub. Once booted using SMP, run uname -a to verify that SMP kernel loaded. Also go through /proc/cpuinfo file.
less /proc/cpuinfo


37
zhili wang 10.08.07 at 10:24 pm
The Linux Admin told me kernel-smp are package for free linux and some old version, we runing advanced linux version and do not need it, it confused me. Is it true?


38
zhili wang 10.10.07 at 3:24 pm
Thanks for all the help.
It is clear now, we did not install smp linux kernel, so there is only one cpu working. Could any one tell me when install Redhat linux on multip cpu server, it will automatically configure to smp kernel or have to maually select the kernel?


39
vivek 10.10.07 at 4:19 pm
zhili,
In most cases it is installed by default but sometime installer cannot detect it and it will install normal kernel. Run yum / up2date command to install SMP kernel from RHN.


40
zhili wang 10.11.07 at 9:12 pm
Vivek,
It is very helpful. Thank you.


41
olfat 11.04.07 at 9:14 am
i find this howto article very useful. thank you!


42
ben 11.16.07 at 3:30 am
is there a GUI version of a CPU usage monitor for KDE? im using fedora 8


43
Daton 12.05.07 at 5:49 pm
Hi, I have a question about iostat command. How can I see the %utilization of disk not %utilization of CPU? I have found out from some of the forums and man page for iostat that the disk utilization report ought to show one parameter called %util. And also somewhere I have found a flag -D to show it but I cannot find anywhere how to configure my command so that it shows this %util field.
Any help is highly appreciated. Thank you.


44
vivek 12.05.07 at 6:28 pm
Daton,
Sometime man page can be confusing..just run iostat -d -x to display disk utilization including %util. It will show TPS (number of transfers per second ) and amount of data read and/or wrtite to/from the device. Try following examples,
iostat -d -x
iostat -d -m -x
iostat -x -d 2
All you have to do is pass -x option.


45
Madivanan 12.07.07 at 9:21 am
everything in a nutshell..excellent Good info


46
Siddharth 12.08.07 at 6:23 am
Very useful information and very well presented! Thanks!


47
uncleremus 01.10.08 at 6:11 pm
You forgot the nicest monitoring tool of them all: gkrellm. Small, fast, nice-looking, must have. Check it out.


48
Vitaly 01.20.08 at 1:24 pm
when we see that certain process takes 10% of CPU and we have 2 CPU server, does it mean – it is 10% from one CPU (==5% of server CPU power ) or 10% from server CPU power (==20% of one CPU)


49
Jamie 01.21.08 at 10:34 am
HI nice tute!
Same question as Vitaly above.
Ina 2 cpus enviroenmnt does the cpu usage percentage mean the percentage the process takes of 2 cpu or both. Please see the above exmple by Vitaly.
Also in your image of the top output. The cpu usage vales for the processes add up to a value (26.8%) greater than the total cpu usage value 23.%)


50
Jacob 01.31.08 at 2:16 pm
You forgot ksysguard in your GUI section. It has a LOT more monitoring ability than the gnome-system-monitor. Here’s a nice article covering its pros and cons:
http://www.linux.com/articles/113700


51
Pirkia.lt admin 02.02.08 at 10:04 pm
top command is better use with argument c (you will get more information):
top c


52
Linux In Israel 02.23.08 at 11:08 pm
Great article! sar is not so popular as it should be …


53
Nicolas 03.31.08 at 7:14 pm
Great intro to CPU usage. Thanks.
The top 10 monopolizing process would be better if sorted as a numberic key :
ps -eo pcpu,pid,user,args | sort -k 1 -r -n | head -10


54
Michael 05.09.08 at 10:03 pm
I have a dual core system. When I type ‘mpstat -P ALL’
10:52:18 PM CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s
10:52:18 PM all 14.33 0.13 2.49 0.43 0.03 0.18 0.00 82.41 151.04
10:52:18 PM 0 15.47 0.13 2.47 0.33 0.00 0.01 0.00 81.59 0.00
10:52:18 PM 1 13.21 0.13 2.51 0.53 0.07 0.35 0.00 83.21 151.04
10:52:18 PM 2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
What is CPU 2?


55
Satya 05.28.08 at 6:11 pm
Hi All,
Today is 5/28/2008 but I ran some performance tests during 5/7/2008.I need to capture the measurements for both Memory and CPU using ‘SAR’ commands for each of 1 minute interval. Is it possible? If yes, what commands should I need to use?
I appreciate your input here.
Thanks
Satya


56
Giuseppe 05.29.08 at 9:04 am
What do you think about cyclesoak?
I wonder if you could provide some example by using it as well.


57
s5h 07.20.08 at 11:27 am
Thanks for writing this, it’s a very good document about how to use proc. Excellent work. Things like this should be in the kernel docs but they just aren’t. Thanks for filling in the gaps.


58
Laena 09.17.08 at 7:56 am
hmmm. how will i make use of the sourcecode used by top command in calling the program to display the processes, to be used in my bankers program in C, to test how bankers handle thing in real time…thanks


59
Will 10.14.08 at 1:58 am
Thanks for the mpstat command. I have a question on how to interpret the CPU usage output from all those commands (top, mpstat, etc)
As from my understanding, when a core is doing stuffs, it is fully occupied, i.e. always 100%. So, is the CPU usage meaning the % use of this CPU since the last reboot? Or is it meaning the % use within a timeframe?
Thanks


60
Will 10.14.08 at 7:01 am
Just to add information to my question above. For mpstat, there is a INTERVAL param. If it is set as 2 seconds, does the output mean the average % CPU usage just within that 2 seconds timeframe?
Thanks.


61
Deano 10.31.08 at 9:22 pm
This was really helpful, thanks!


62
James 11.03.08 at 2:15 pm
Is there a way to query the overall system usage say in a Perl script or something? I have a low power Linux (or XP it could be) box and want it to postpone some activity for 5 minutes if the CPU loading is say over 30%.
In simple terms
If CPU Usage > 30% then Wait 300 Seconds
Can that be done?-


63
Priya 11.08.08 at 4:28 am
i want to know how can we find the processor id of a system with two processors through linux using c


64
Louis Wang 12.31.08 at 5:52 am
Vivek,
Great article!
I have a question. I am confused by “%CPU” in top. One user process used 100% CPU, but the system still have 89% idle, not 0% idle. How to understand it?
Regards,
Louis
$ top |head -8
top – 12:50:45 up 33 days, 19:32, 4 users, load average: 1.06, 1.05, 1.00
Tasks: 234 total, 2 running, 229 sleeping, 1 stopped, 2 zombie
Cpu(s): 9.1%us, 1.7%sy, 0.0%ni, 89.0%id, 0.1%wa, 0.0%hi, 0.1%si, 0.0%st
Mem: 3894760k total, 3708140k used, 186620k free, 239680k buffers
Swap: 2031608k total, 17700k used, 2013908k free, 2374436k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
3595 otrs 25 0 26712 21m 3840 R 99 0.6 17931:35 PostMasterMailb
$ mpstat -P ALL
Linux 2.6.18-8.el5 (xxxxxxxxx) 12/31/2008
12:54:42 PM CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s
12:54:42 PM all 9.09 0.00 1.67 0.07 0.01 0.13 0.00 89.03 1018.11
12:54:42 PM 0 1.93 0.00 0.31 0.11 0.00 0.03 0.00 97.62 255.65
12:54:42 PM 1 9.78 0.00 1.68 0.04 0.01 0.13 0.00 88.37 254.53
12:54:42 PM 2 2.48 0.00 0.40 0.11 0.00 0.03 0.00 96.97 253.35
12:54:42 PM 3 22.16 0.00 4.31 0.02 0.01 0.35 0.00 73.16 254.58


65
Vivek Gite 12.31.08 at 10:05 am
Louis,
It may be possible that user is using 100% CPU core or one of other CPU in multiprocessor system.


66
Ramesh 01.05.09 at 8:56 am
Hi Vivek,
that is a goos article. hope you can help me in this small issue.
i have got lighttpd running and i need to develop test cases and run tests – provide dynamic content with HTML. use options like cgi, fastcgi, ajax etc.
i want to monitor the resource usage of lighttpd during each test.
please do reply. thanks


67
Ramesh 01.05.09 at 11:28 am
sorry.. i mean..good..type(goos)..sorry


68
Youvedeep Singh 01.17.09 at 1:27 pm
Hi all
It’s a nice article
I want to relate the CPU utilization with the energy consumed by the ststem, is there any way to do so.
Or there is an alternate way to find the energy consumed by all the processes.
Regards
Youvedeep Singh


69
Vikrant 01.26.09 at 7:27 pm
Hey all! Nice article
Can anyone tell me where is this information stored? For example in unix systems at /proc/uptime gives information of uptime of the system and the value is dynamic since it would be different every time you poll. Which file stores such information for CPU utilization? So I can “cat and get the information that how much CPU has been utilized?
Any help is appreciated.
Best Regards
Vikrant


70
shapirus 01.30.09 at 10:53 pm
Can someone please explain me how can it be when /proc/stats shows 414% total CPU usage (including the idle time) on a quad-core single processor box?
Example:
$ cat /proc/stat|grep “^cpu “;sleep 100;cat /proc/stat|grep “^cpu ”
cpu 102843 0 66548 4308888 773304 9547 30153 0 0
cpu 103568 0 67109 4345597 776311 9655 30471 0 0
if we subtract the sets of numbers from each other, divide by 100 and sum them, we’ll find that they add up to 414.28. How can it be? I use RHEL 5 with 2.6.28.2 kernel with dynamic ticks and multi-core scheduler support.
Thanks.


71
shapirus 01.31.09 at 4:12 pm
Found it out. The bug (feature?) was in the CONFIG_NO_HZ option. I guess the kernel calculates the idle time inaccurately when the dynamic ticks are turned on. However I also have a few other 32-bit boxes (that one was 64-bit) where this issue does not occur and one 32-bit where it does.
Weird.


72
Youvedeep Singh 02.02.09 at 7:30 pm
hi
In one of my college project i require the energy consumed by the System.
Is there any way to find the Power/Energy consumed by the CPU/Disk/IOs.
If anyone is aware of any of such method, please reply fast, i require it urgently.
Regards
Youvedeep Singh


73
Nicholas 02.20.09 at 7:02 am
How I get the word size (32bit or 64bit) of a particular server running on Linux
Linux express.sagt.com.lk 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:54:53 EST 2006 i686 i686 i386 GNU/Linux
Thanks
Nic


74
J_Tom_Moon_79 02.22.09 at 11:16 pm
# on fedora core (can install with yum)
$ dstat


75
J_Tom_Moon_79 02.22.09 at 11:18 pm
# (to find more, just hunt through the output of this cmd)
$ yum search stat


76
J_Tom_Moon_79 02.23.09 at 12:14 am
# (or manually search through the output of yum)
$ yum search stat


77
mohamed 03.01.09 at 5:53 am
I found this article really helpful, thank you, keep up the good work.


78
Tini 03.26.09 at 6:50 am
This article really helped me a lot.
Thanks a lot


79
nic 04.02.09 at 8:49 pm
Using “k -pcpu” will accomplish the reverse sorting as well (including taking care of proper numeric sorting on multi-cpu machines):
ps k -pcpu -eo pcpu,pid,user,args | head -10


80
Sanjay 05.15.09 at 2:13 pm
Thanks a ton!!! very awesome article and this whole long thread :)


81
Pavel 05.19.09 at 11:08 pm
hi hi well…. i have 1question.. ahmm….letme se…. ihave a Red hat 5 linux and glassfish aplication server an’ when i try to monitoring the server i see something like …. well ….
top – 17:41:08 up 1 day, 6:37, 4 users, load average: 1.12, 1.12, 1.11
Tasks: 159 total, 1 running, 153 sleeping, 5 stopped, 0 zombie
Cpu(s): 26.5%us, 0.2%sy, 0.0%ni, 73.1%id, 0.0%wa, 0.0%hi, 0.2%si, 0.0%st
Mem: 3365124k total, 3124404k used, 240720k free, 4400k buffers
Swap: 8385888k total, 246344k used, 8139544k free, 71892k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
12001 root 20 0 1633m 593m 11m S 102 18.0 218:19.97 java
28432 root 22 0 1641m 330m 13m S 2 10.1 2:06.12 java
28611 root 25 0 1642m 228m 12m S 2 6.9 2:25.95 java
28528 root 19 0 2253m 920m 13m S 1 28.0 10:43.70 java
1 root 15 0 2036 556 524 S 0 0.0 0:00.84
as u’ can see mi cpu it’s burning or something like that …. someone knows why a glassfish domain only increese i mind…just eat ram memory…. someone knows.. why….. jus whyy !!! why!!!!! T_T


82
Vivek Gite 05.20.09 at 7:46 am
Your load average looks normal to me. Run free -m command to see memory usage.


83
Pavel 05.20.09 at 5:09 pm
ahmm….. really?….. well…. ahm…. the server in the graphic mode runs to slowly and welllit’s a little server i think cuz just have 3.5gb in Ram , but as u’ can se in my example the proces quickly the ram downs……i mind… i don’t know i think……


84
Joe 07.02.09 at 2:20 am
Good info here. I like the “top|head -5″ in particular – everything in one nutshell. Can someone please explain the CPU load percentage as it relates to multi-core or multi-cpu machines. If I see a load of 1.57 (157%) on a Xeon (quad processor), is that 1.57 out of a possible 4.00, or are all 4 CPUs running flat out and swapping the 57% overhead? Also, is there an easy way to get a CPU count to adjust the load statistic if needed? From the above the best I got was “cat /proc/cpuinfo|grep processor|wc -l” – but I don’t suspect it would ‘port’ from RedHat to a Sun, HP or AIX box.


85
Avish Aren 07.03.09 at 6:53 am
On a machine with 4 processors running Linux, what would a CPU load of 2 mean?


86
Avish Aren 07.03.09 at 6:54 am
Show me a command that would search for a given line of text in all files in the current directory tree older than 2 months without using pipes


87
Avish Aren 07.03.09 at 6:54 am
While looking in an application log file, you see a line to the effect of “Cannot bind to address: 1.2.3.4 address already in use”; what does this indicate?


88
ant 07.10.09 at 5:37 am
ps can also sort the output
ps -eo pcpu,vsize,rss,pid,user,args –sort -pcpu
i am using this now in a monitoring script so as soon as something goes wrong i can get a snapshot of the cpu hog, and check up on process memory usage as well.


89
Anurag Srivastav 08.25.09 at 8:54 am
Your posting seems to be helpful. I suggest you to add some info about vmstat command


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/7869/showart_2038235.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP