Skip to content

Instantly share code, notes, and snippets.

@nkwhr
Created May 4, 2012
Embed
What would you like to do?
#!/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