Skip to content

Instantly share code, notes, and snippets.

@nkwhr
Created May 4, 2012 12:07
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nkwhr/2594448 to your computer and use it in GitHub Desktop.
#!/bin/sh
_RSS=0
_SHARED=0
_PID=$1
_SMAPS=`cat /proc/$_PID/smaps`
for i in `echo "$_SMAPS" | grep 'Rss' | awk '{print $2}'`; do
_RSS=`expr $_RSS + $i`
done
for j in `echo "$_SMAPS" | grep 'Shared' | awk '{print $2}'`; do
_SHARED=`expr $_SHARED + $j`
done
_RATIO=`echo "scale=2; $_SHARED / $_RSS * 100" | bc`
echo -e "PID=$_PID \t RSS=$_RSS \t SHARED=$_SHARED ($_RATIO%)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment