Who is eating my CPU Print

  • 0

One of the most useful Server admin tool is the almighty “top”..with it we can have a lot of information in just one shot.

top - 18:29:10 up 1:17, 1 user, load average: 35.56, 26.46, 20.72
Tasks: 457 total, 2 running, 454 sleeping, 0 stopped, 1 zombie
Cpu(s): 48.8%us, 3.1%sy, 0.0%ni, 28.2%id, 19.9%wa, 0.0%hi, 0.1%si, 0.0%st
Mem: 16302796k total, 13954896k used, 2347900k free, 321576k buffers
Swap: 4095996k total, 0k used, 4095996k free, 8737056k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
 3096 mysql 20 0 9319m 2.5g 13m S 709.9 15.8 258:33.23 mysqld
28353 pegit 20 0 168m 17m 8504 D 16.3 0.1 0:00.10 php
28314 pegit 20 0 168m 17m 8512 D 14.5 0.1 0:00.11 php
28492 pegit 20 0 168m 17m 8512 D 7.3 0.1 0:00.11 php
28646 pegit 20 0 169m 18m 8860 D 7.3 0.1 0:00.12 php
15158 nobody 20 0 81112 8168 3200 S 5.4 0.1 0:00.79 httpd
 9953 nobody 20 0 87652 8348 3268 S 3.6 0.1 0:00.90 httpd
 9960 nobody 20 0 87588 8240 3312 S 1.8 0.1 0:00.98 httpd
27628 nobody 20 0 80780 6876 2240 S 1.8 0.0 0:00.06 httpd
28650 root 20 0 13392 1412 820 R 1.8 0.0 0:00.01 top
28651 pegit 20 0 142m 9700 5972 S 1.8 0.1 0:00.01 php
 1 root 20 0 19360 1560 1240 S 0.0 0.0 0:00.83 init

you can use the “htop” utility as well, if you have it already installed in your Linux both…htop allows you to sort your server variables and a few other “cool things”

 1 [|||||||||||||||||||||||||||||||||||||||||| 37.9%] 5 [|||||||||||||||||||||||||||||||||||||| 34.6%]
 2 [||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 74.1%] 6 [||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||100.0%]
 3 [|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 68.2%] 7 [|||||||||||||||||||||||||||||||||||||||||||||||||| 44.8%]
 4 [|||||||||||||||||||||||||||||||| 28.3%] 8 [|||||||||||||||||||||||||||||||||||||||||||||||||||| 46.9%]
 Mem[||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 4935/15920MB] Tasks: 244, 209 thr; 5 running
 Swp[ 0/3999MB] Load average: 26.28 26.48 21.25
 Uptime: 01:19:03

PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
 3096 mysql 20 0 9319M 2514M 13756 S 343. 15.8 4h24:23 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/server.shop2cure.org.err --open-files-li
29043 pegit 20 0 186M 40628 12228 R 94.6 0.2 0:09.77 /usr/bin/php /home/pegit/public_html/movies/index.php
29143 pegit 20 0 258M 106M 8804 R 92.3 0.7 0:02.04 /usr/bin/php /home/pegit/public_html/movies/index.php
 3722 mysql 20 0 9319M 2514M 13756 S 68.1 15.8 2:55.61 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/server.shop2cure.org.err --open-files-li
 3620 mysql 20 0 9319M 2514M 13756 S 44.5 15.8 2:48.62 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/server.shop2cure.org.err --open-files-li
 5855 mysql 20 0 9319M 2514M 13756 S 44.0 15.8 3:24.46 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/server.shop2cure.org.err --open-files-li
 4134 mysql 20 0 9319M 2514M 13756 S 42.6 15.8 2:59.65 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/server.shop2cure.org.err --open-files-li
 3713 mysql 20 0 9319M 2514M 13756 S 35.0 15.8 3:05.42 /usr/sbin/mysqld --basedir=/usr --datadir=/va

Sometimes there is just to much information to process. so i prefer going to the root of the situation, and run these commands to find where the CPU resources are going to:

# ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10

OR

# ps -eo pcpu,pid,user,args | sort -r -k1 | less

Was this answer helpful?

« Back