SUSEUnbound
Would you like to react to this message? Create an account in a few clicks or log in to continue.


 
HomeHome  PortalPortal  Latest imagesLatest images  SearchSearch  RegisterRegister  Log in  
openFate
Show RAM and SWAP usage in a simple and pretty manner Fatelogo_small openFATE - openSUSE feature tracking
Latest topics
» Difference between 42.2 and 42.1
Show RAM and SWAP usage in a simple and pretty manner Emptyby findoctr Thu Dec 15, 2016 7:53 pm

» openSUSE Leap 42.1 ?
Show RAM and SWAP usage in a simple and pretty manner Emptyby findoctr Fri Feb 05, 2016 8:09 pm

» Happy Turkey Day
Show RAM and SWAP usage in a simple and pretty manner Emptyby findoctr Thu Nov 26, 2015 1:45 pm

» Happy 4th of July!
Show RAM and SWAP usage in a simple and pretty manner Emptyby bozo Sat Jul 04, 2015 12:56 pm

» It's been a while ...
Show RAM and SWAP usage in a simple and pretty manner Emptyby bozo Mon Feb 23, 2015 8:34 pm

» Mondo chillers
Show RAM and SWAP usage in a simple and pretty manner Emptyby bozo Wed Feb 18, 2015 5:11 am

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search
IRC Channel
You can also find us on IRC's freenode.net as #suseunbound.

 

 Show RAM and SWAP usage in a simple and pretty manner

Go down 
AuthorMessage
welan
Admin
welan


Posts : 248
Join date : 2010-02-23
Age : 61
Location : snow drift in minnesota

Show RAM and SWAP usage in a simple and pretty manner Empty
PostSubject: Show RAM and SWAP usage in a simple and pretty manner   Show RAM and SWAP usage in a simple and pretty manner EmptyMon Mar 15, 2010 5:52 pm

#!/bin/sh

drawChart()
{
COUNT=0
MAX=30
CHARTWIDTH=`expr $MAX - 2`
CHARTUSED=`expr $2 '*' $MAX / $1`
CHARTFREE=`expr $CHARTWIDTH - $CHARTUSED`

echo -n "["
while [ $COUNT -lt $MAX ] ;
do
if [ $COUNT -lt $CHARTUSED ]; then
echo -n "#"
else
echo -n "."
fi
COUNT=`expr $COUNT + 1`
done
echo "] ($3% occupied)"
}

RAM=`free -m | grep Mem`
SWAP=`free -m | grep Swap`

RAMTOTAL=`echo $RAM | awk '{ print $2 }'`
RAMUSED=`echo $RAM | awk '{ print $3 }'`

SWAPTOTAL=`echo $SWAP | awk '{ print $2 }'`
SWAPUSED=`echo $SWAP | awk '{ print $3 }'`

RAMPERCENT=`expr 100 '*' $RAMUSED '/' $RAMTOTAL`
SWAPPERCENT=`expr 100 '*' $SWAPUSED '/' $SWAPTOTAL`

echo "RAM (total: $RAMTOTAL MB; used: $RAMUSED MB)"
drawChart $RAMTOTAL $RAMUSED $RAMPERCENT

echo

echo "SWAP (total: $SWAPTOTAL MB; used: $SWAPUSED MB)"
drawChart $SWAPTOTAL $SWAPUSED $SWAPPERCENT
Back to top Go down
 
Show RAM and SWAP usage in a simple and pretty manner
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
SUSEUnbound :: Help Section :: Tips and Tweaks-
Jump to: