17

RAM Meter

Posted in System by matt 3181 days ago

Inspired by the CPU meter posted by blair1618, Vanglad posted the code for this RAM Meter in the comments. The code didn't display very well, so here's a downloadable .glet file that you can use instead.

myRAM=`top -l 1 -F -R | awk '/PhysMem/ {print "" $8+0}'`
totalRAM=2048
myPercentRAM=`expr $myRAM \* 100 / $totalRAM`
declare -i a=5 
while [ $a -lt $myPercentRAM ] 
do
    echo "|\c"
    a=`expr $a + 5`
done
echo "\033[1;31m|\033[0m\c"
while [ $a -lt 100 ] 
do
    echo "\033[1;30m|\033[0m\c" 
    a=`expr $a + 5`
done
echo "\n"
unset myRAM
unset myPercentRAM
unset a

Geeklet files to download

Comments

User Avatar
chuckles911 3145 days ago
Hey, well, when i download this and run it i only get a bar of white lines?  i cant get it to display anything, and i know my RAM isnt like, freaking out so... Help?
User Avatar
Stelkeeg 3130 days ago
It's freaking out because it's reading your computer only has 2048 mb of RAM, and since your probably running over that amount it prints the gauge as full.  Fortunately there is a quick fix.  You have to edit the second line of the script, where it says:

totalRAM=2048

CHANGE ONLY THE NUMBER.  The number is the total amount of RAM you have in YOUR computer in megabytes.  So if you have 4GB you would put 4000.  This should make the meter read properly. 

 

Log in to comment or register here.