9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Robert Raschke <rrplan9@tombob.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] memory
Date: Thu, 27 Jan 2005 12:42:43 +0000	[thread overview]
Message-ID: <7ed2763a9561e1f9fa3067d1566639ad@tombob.com> (raw)
In-Reply-To: <4d5848ebc16d0227918a0fa9c8327e94@plan9.ucalgary.ca>

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



  reply	other threads:[~2005-01-27 12:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-26 10:07 cej
2005-01-26 10:58 ` Heiko Dudzus
2005-01-27  0:17 ` Tim Newsham
2005-01-27  0:45   ` geoff
2005-01-27  1:05     ` andrey mirtchovski
2005-01-27 12:42       ` Robert Raschke [this message]
2005-01-28 10:03         ` arisawa
  -- strict thread matches above, loose matches on Subject: below --
2005-02-07  7:16 tapique
2005-02-08  4:52 ` Russ Cox
2005-02-08  5:12   ` Lucio De Re
2000-11-21 13:28 presotto
2000-11-20 20:48 Russ Cox
2000-11-20 21:04 ` Boyd Roberts
2000-11-20 21:49 ` Mike Haertel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7ed2763a9561e1f9fa3067d1566639ad@tombob.com \
    --to=rrplan9@tombob.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).