Logo address

Memory Used

	From: 	  arisawa@ar.aichi-u.ac.jp
	Subject: 	Re: [9fans] memory
	Date: 	2005年1月28日 19:03:30:JST
	To: 	  9fans@cse.psu.edu
	Reply-To: 	  9fans@cse.psu.edu

Just translation from Robert, avoiding zero division.

#!/bin/rc
all=`{cat /dev/swap | sed 's,/, ,g'}
echo '
pageinmb = 4096/(1024*1024)
mem = '$all(1)^'*pageinmb
memtotal = '$all(2)^'*pageinmb
memperc = mem*100/memtotal
swap = '$all(4)^'*pageinmb
swaptotal = '$all(5)^'*pageinmb
if(swaptotal != 0){
        swapperc = swap*100/swaptotal
} else {
        swapperc = 0
}
print "memory: ",int(mem),"MB used (",int(memperc),"% of ",int(memtotal),"MB).\n"
print "swap: ",int(swap),"MB used (",int(swapperc),"% of ",int(swaptotal),"MB).\n"
' | hoc


Kenji Arisawa