Guest User

Untitled

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