Home > Bookmarks, Linux > linux cpu usage

linux cpu usage

October 9th, 2007 Leave a comment Go to comments

Type the top command:

# top

top - 16:54:34 up 15 days, 13:29,  1 user,  load average: 0.30, 0.18, 0.23Tasks: 136 total,   1 running, 134 sleeping,   1 stopped,   0 zombie
Cpu(s):  9.5%us,  1.8%sy,  0.0%ni, 88.5%id,  0.0%wa,  0.0%hi,  0.2%si,  0.0%stMem:   1026584k total,   886792k used,   139792k free,    78664k buffers
Swap:  2096472k total,   197728k used,  1898744k free,   377476k cached
PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
28780 apache    20   0 59432  21m 6236 S   13  2.1   4:00.40 httpd
24553 mysql     20   0  152m  19m 2976 S    9  1.9 979:12.36 mysqld
12124 root      20   0  2200 1028  796 R    0  0.1   0:00.02 top
1 root      20   0  2040  472  444 S    0  0.0   0:10.80 init
2 root      15  -5     0    0    0 S    0  0.0   0:00.00 kthreadd

or with sysstat

For install sysstat in FedoraCore:

# yum install sysstat

after install use command:

# mpstat 1 10

04:59:25 PM  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s
04:59:26 PM  all    7.96    0.00    1.00    0.00    0.00    0.00    0.00   91.04     54.00
04:59:27 PM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00     42.57
04:59:28 PM  all    9.00    0.00    0.00    0.00    0.00    0.00    0.00   91.00     21.00
04:59:29 PM  all    8.54    0.00    0.50    0.00    0.00    0.00    0.00   90.95     41.00
04:59:30 PM  all   18.00    0.00    1.00    0.00    0.00    0.00    0.00   81.00     78.0
04:59:31 PM  all    0.00    0.00    0.50    0.00    0.00    0.50    0.00   99.01     78.00

who is monopolizing the CPUs ?
use:

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

%CPU   PID USER     COMMAND
4.3 24553 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-external-locking --socket=/var/lib/mysql/mysql.sock
1.2 32501 apache   /usr/sbin/httpd
1.2 28803 apache   /usr/sbin/httpd
1.2 28780 apache   /usr/sbin/httpd
1.2  2825 apache   /usr/sbin/httpd
1.1  5893 apache   /usr/sbin/httpd
1.1  4080 apache   /usr/sbin/httpd
1.1  4042 apache   /usr/sbin/httpd
1.1  4029 apache   /usr/sbin/httpd
Categories: Bookmarks, Linux Tags: , , , , , ,
  1. No comments yet.
  1. No trackbacks yet.
GoCache - ByREV-Cache v1.0 - live served in : 0.244417 sec (gzip)