Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- size total program size
- (same as VmSize in /proc/[pid]/status)
- resident resident set size
- (same as VmRSS in /proc/[pid]/status)
- share shared pages (from shared mappings)
- data data + stack
- #!/usr/bin/env bash
- ## Print header
- echo -e "SizetResid.tSharedtDatat%"
- while [ 1 ]; do
- ## Get the PID of the process name given as argument 1
- pidno=`pgrep $1`
- ## If the process is running, print the memory usage
- if [ -e /proc/$pidno/statm ]; then
- ## Get the memory info
- m=`awk '{OFS="t";print $1,$2,$3,$6}' /proc/$pidno/statm`
- ## Get the memory percentage
- perc=`top -bd .10 -p $pidno -n 1 | grep $pidno | gawk '{print $10}'`
- ## print the results
- echo -e "$mt$perc";
- ## If the process is not running
- else
- echo "$1 is not running";
- fi
- done
- $ memusage.sh firefox
- Size Resid. Shared Data %
- 517193 261902 9546 400715 12.8
- 517193 261902 9546 400715 12.8
- 517193 261902 9546 400715 12.8
- 517193 262100 9546 400715 12.8
- 517193 262100 9546 400715 12.8
- 517193 262100 9546 400715 12.8
- 517209 261899 9546 400731 12.8
- 517209 261899 9546 400731 12.8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement