daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest May 16th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
Top