Created
          February 22, 2012 17:05 
        
      - 
      
- 
        Save morsik/1886095 to your computer and use it in GitHub Desktop. 
    Calculates RAM usage by some program
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| # Author: Konrad (morsik) Mosoń | |
| # Usage: ./calcram.sh chromium | |
| SUM=0 | |
| OUT=`ps aux | grep $1 | awk '{print $4}'` | |
| for n in $OUT | |
| do | |
| SUM=`echo "$SUM + $n" | bc` | |
| done | |
| ALLRAM=`cat /proc/meminfo | grep MemTotal: | awk '{print $2}'` | |
| USEDRAM=`echo "(($SUM) * ($ALLRAM / 1024)) / 100" | bc` | |
| echo "$USEDRAM" M | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment