Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- echo -e "PID\tVSZ\tRSS\tShared"
- for pid in $@; do
- smaps="/proc/$pid/smaps"
- vsz=$(grep -E "^Size" $smaps | awk 'BEGIN{ num = 0 } { num += $2 } END{ print num }')
- rss=$(grep -E "^Rss" $smaps | awk 'BEGIN{ num = 0 } { num += $2 } END{ print num }')
- shared=$(grep -E "^Shared" $smaps | awk 'BEGIN{ num = 0 } { num += $2 } END{ print num }')
- percent=$(echo "scale=2; ($shared / $rss) * 100" | bc | cut -d "." -f 1)
- echo -e "$pid\t${vsz}KB\t${rss}KB\t${shared}KB(${percent}%)"
- done
Add Comment
Please, Sign In to add comment