VMSTAT
vmstat 1
htop
sudo apt-get install -y htop sudo htop
atop
sudo apt-get install atop -y sudo atop
How to Find the Most Memory taking process in Ubuntu Linux
Some Times system administrators need to kill the memory eater process. When your system become slower, check the following command and find the memory eater.
Open a terminal and Type the following command
ps aux | sort -nrk 4 | head
Sysstat
sudo apt-get install sysstat -y
mpstat -> contained in sysstat
mpstat 1 => mpstat every second
Memory monitoring of a give Process
cat /proc/meminfo
System memory allocation
freeempty / free up memory caches
To free pagecache:
echo 1 > sudo /proc/sys/vm/drop_cachesTo free dentries and inodes:
echo 2 > sudo /proc/sys/vm/drop_cachesTo free pagecache, dentries and inodes:
echo 3 > sudo /proc/sys/vm/drop_cachesAs this is a non-destructive operation and dirty objects are not freeable, the user should run “sync” first!
This was originally found @ http://www.linuxinsight.com/proc_sys_vm_drop_caches.htmlLoop free memory bash
while true; do free -m; sleep 1; done while :; do free -m; sleep 1; doneMemory & CPU Utilisation
ps -eo pcpu,%mem,cmd|sort -k2 -r ps -eo pcpu,%mem,cmd|sort -k2 -r|head -3See also http://www.unix.com/shell-programming-scripting/65947-memory-cpu-utilization-process.html
top -ptop -p 20832 process id from name
ps -ef | grep w.py|grep -v grep | awk '{print $2}'top for only
top -p `ps -ef | grep w.py|grep -v grep | awk '{print $2}'` one process by nameMachine CPU - using ps aux
while :; do ps aux|awk 'NR > 0 { s +=$3 }; END {print s"%"}'; sleep 1; doneSee also: http://bashscripts.org/forum/viewtopic.php?f=15&t=1237 and http://www.linuxquestions.org/questions/linux-newbie-8/how-to-get-cpu-usage-of-a-process-63726/
Process CPU - using ps uax
while :; do ps aux|grep w.py|awk 'NR > 0 { s +=$3 }; END {print s"%"}'; sleep 1; done => very inaccurateProcess CPU - using top
while :; do top -c -b -n 1|grep w.py; sleep 1; done => this is more accurateEven better!
#while :; do top -c -b -n 1|grep w.py|grep -v grep|awk '{print $10}'; sleep 1; done while :; do top -c -b -n 1|grep w.py|grep -v grep|awk '{print $9}'; sleep 1; done while :; do i=$((i+1)); echo $i ; top -c -b -n 1|grep w.py|grep -v grep|awk '{print $9}'; sleep 1; donLoad - General
w|grep loadLoad - Using uptime
while :; do uptime | awk '{print $10}'; sleep 1; done#!/bin/bash loadavg=`uptime | awk '{print $10}'` # bash doesn't understand floating point # so convert the number to an interger thisloadavg=`echo $loadavg|awk -F \. '{print $1}'` if [ "$thisloadavg" -ge "2" ]; then echo "Busy - Load Average $loadavg ($thisloadavg) " top -bn 1 else echo "Okay - Load Average $loadavg ($thisloadavg) " fiReferences
1. http://www.linuxquestions.org/questions/programming-9/check-server-load-with-bash-703464/
2. http://freetofeel.com/page3/
3. http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html
4. http://www.shibuvarkala.com/2010/06/how-to-find-most-memory-taking-process.html