On Linux platform  we are managing our system by commands on terminal. It's often important to check system load like, CPU utilize as percentage wise, memory used per process wise, users resource usage.

For example we taken a website, If the server is loading on time or site would become very slow access, we need to check cpu and memory utilization.
  
Can use commands are "free" or "top",

# free -m

The above command to check RAM memory usages and '-m' option display with MB size for users read.

 
# top 

The top command is displaying all the details like memory, cpu usage, and others. Also we have discribed on previous post

The below command displays divided by CPU usage percentage wise, pid, users who are currently accessing and commands.


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

%CPU   PID USER     COMMAND
87.0  4440 thelinuxfaq   /usr/bin/php /home/thelinuxfaq/public_html/index.php
 8.5  4349 thelinuxfaq   /usr/bin/php /home/thelinuxfaq/public_html/index.php
 7.6  4344 thelinuxfaq   /usr/bin/php /home/thelinuxfaq/public_html/index.php
 6.5  4339 thelinuxfaq   /usr/bin/php /home/thelinuxfaq/public_html/index.php
 5.5  4334 thelinuxfaq   /usr/bin/php /home/thelinuxfaq/public_html/index.php
 5.5  4329 thelinuxfaq   /usr/bin/php /home/thelinuxfaq/public_html/index.php
 4.8  4321 thelinuxfaq   /usr/bin/php /home/thelinuxfaq/public_html/index.php
12.5  1353 mysql    /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/host.hostname.com.err --open-files-limit=10000 --pid-file=/var/lib/mysql/host.favkart.com.pid

This command show specific process id usage (CPU, Memory and command

ps -p <pid> -o %cpu,%mem,cmd
 
# ps -p 2174  -o  %cpu,%mem,cmd

%CPU %MEM CMD
26.8  0.1 /usr/lib/xen/bin/qemu-dm

To know particular process usage, for example view the details about firefox.
 
# ps -C firefox -o %cpu,%mem,cmd

%CPU %MEM CMD
 9.3 17.9 /usr/lib/firefox/firefox


All process :
 
ps aux | awk '{print $4"\t"$11}' | sort | uniq -c | awk '{print $2" "$1" "$3}' 


per process :
 
ps aux | awk '{print $4"\t"$11}' | sort | uniq -c | awk '{print $2" "$1" "$3}' 
ps aux | awk '{print $4"\t"$11}' | sort | uniq -c | awk '{print $2" "$1" "$3}' 


Also use this script,

Download a script from the below url using wget command,

Give to execute permission and run python script,
 

# wget https://raw.githubusercontent.com/pixelb/ps_mem/master/ps_mem.py

# chmod +x ps_mem.py

# python  ps_mem.py
 

 Private  +   Shared  =  RAM used       Program

  4.0 KiB +  12.5 KiB =  16.5 KiB       agetty
  4.0 KiB +  18.5 KiB =  22.5 KiB       mysqld_safe
  ....
  9.8 MiB +  71.0 KiB =   9.9 MiB       named
  9.8 MiB +   3.5 MiB =  13.3 MiB       httpd (6)
 23.1 MiB +  37.5 KiB =  23.1 MiB       memcached
 34.0 MiB + 158.5 KiB =  34.1 MiB       mysqld
  2.4 GiB +   9.2 MiB =   1.4 GiB       php (38)
---------------------------------
                          1.9 GiB
=================================