From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <7ed2763a9561e1f9fa3067d1566639ad@tombob.com> To: 9fans@cse.psu.edu Subject: Re: [9fans] memory Date: Thu, 27 Jan 2005 12:42:43 +0000 From: Robert Raschke In-Reply-To: <4d5848ebc16d0227918a0fa9c8327e94@plan9.ucalgary.ca> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 37b0a5d2-eace-11e9-9e20-41e7f4b1d025 After Andrey sent round his useful little script recently, I tarted it up ever so slightly to show percentages, and since I only think in MB these days, added some truncating: cpu% cat /bin/mem #!/bin/rc # show available and used memory in # user-discernible format. # Thanks goes to Andrey Mirtchovski for the original. all=`{cat /dev/swap | sed 's,/, ,g'} pageinmb = `{echo '4096/(1024*1024)' | hoc } mem = `{echo 'int('^$all(1)^'*'^$pageinmb^')' | hoc } memtotal = `{echo 'int('^$all(2)^'*'^$pageinmb^')' | hoc} memperc = `{echo 'int('^$mem^'*100/'^$memtotal^')' | hoc} swap = `{echo 'int('^$all(4)^'*'^$pageinmb^')' | hoc } swaptotal = `{echo 'int('^$all(5)^'*'^$pageinmb^')' | hoc} swapperc = `{echo 'int('^$swap^'*100/'^$swaptotal^')' | hoc} echo 'memory: '^$mem^' MB used ('^$memperc^'% of '^$memtotal^' MB).' echo 'swap: '^$swap^' MB used ('^$swapperc^'% of '^$swaptotal^' MB).' cpu% mem memory: 37 MB used (42% of 87 MB). swap: 0 MB used (0% of 512 MB). cpu% Robby