Skip to content

Instantly share code, notes, and snippets.

@nshenry03
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nshenry03/90d68840f9ecdea80c80 to your computer and use it in GitHub Desktop.
Save nshenry03/90d68840f9ecdea80c80 to your computer and use it in GitHub Desktop.
Get a summary of per process memory usage using awk (php-fpm for example). Note, if a process shares libraries, they will be counted multiple times so this isn't perfect; however, it should give you a good rough summary of the amount of memory used.
ps aux | fgrep php-fpm | egrep -v 'master process|fgrep' | sort -k13 | awk '{print $1,$6}' | awk '{a[$1]+=$2;}END{for(i in a)print i, a[i] * 0.001;}' | sort -nr -k2 | awk '{ sum+=$2 ; print $1, $2, " MB"} END {print "Total Memory Usage:", sum, " MB"}'
lilnbboj 268.368 MB
zkrmkprl 221.532 MB
yfjoubng 212.532 MB
rjnjpbqg 209.78 MB
dvpqmqss 141.96 MB
paxsqasd 130.288 MB
lgtuwbau 118.284 MB
bgougjoq 117.36 MB
mhffauvt 30.292 MB
wxsdlnag 30.28 MB
tillfpoo 30.28 MB
bbsahigr 18.18 MB
ariorpev 18.168 MB
ulzmupsw 18.16 MB
uxtodijm 18.156 MB
njqugpvs 18.156 MB
mvldssjn 18.156 MB
dzhsazkm 18.152 MB
wuruxrrn 18.144 MB
goulhkdr 18.144 MB
xhhlhxag 18.132 MB
ujepetxu 18.132 MB
rtagkhxk 18.124 MB
Total Memory Usage: 1728.76 MB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment