Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. size total program size
  2. (same as VmSize in /proc/[pid]/status)
  3. resident resident set size
  4. (same as VmRSS in /proc/[pid]/status)
  5. share shared pages (from shared mappings)
  6. data data + stack
  7.  
  8. #!/usr/bin/env bash
  9.  
  10. ## Print header
  11. echo -e "SizetResid.tSharedtDatat%"
  12. while [ 1 ]; do
  13. ## Get the PID of the process name given as argument 1
  14. pidno=`pgrep $1`
  15. ## If the process is running, print the memory usage
  16. if [ -e /proc/$pidno/statm ]; then
  17. ## Get the memory info
  18. m=`awk '{OFS="t";print $1,$2,$3,$6}' /proc/$pidno/statm`
  19. ## Get the memory percentage
  20. perc=`top -bd .10 -p $pidno -n 1 | grep $pidno | gawk '{print $10}'`
  21. ## print the results
  22. echo -e "$mt$perc";
  23. ## If the process is not running
  24. else
  25. echo "$1 is not running";
  26. fi
  27. done
  28.  
  29. $ memusage.sh firefox
  30. Size Resid. Shared Data %
  31. 517193 261902 9546 400715 12.8
  32. 517193 261902 9546 400715 12.8
  33. 517193 261902 9546 400715 12.8
  34. 517193 262100 9546 400715 12.8
  35. 517193 262100 9546 400715 12.8
  36. 517193 262100 9546 400715 12.8
  37. 517209 261899 9546 400731 12.8
  38. 517209 261899 9546 400731 12.8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement