[vox-tech] [fwd] [svlug] Question regarding top
Bill Kendrick
nbs at sonic.net
Tue Jun 13 10:29:37 PDT 2006
I thought this was pretty cool. 'course, I'm a total newbie with awk. ;)
At the least, it might be useful.
-bill!
----- Forwarded message from Seth David Schoen -----
Date: Tue, 13 Jun 2006 00:16:28 +0100
From: Seth David Schoen
Subject: Re: [svlug] Question regarding top
To: stripes
stripes writes:
> Hi all,
>
> I've looked around through /etc/toprc and ~/.toprc, and I can't find any
> way to format the output so it gives memory in MB (instead of kb).
>
> Is there anyway to do that on top, or do I need to use the free command
> (where I can).
You could modify the source code of top (it's in the procps package).
There doesn't seem to be an existing option in the source code to do
this.
If you don't need to be portable to other Unixes, you might enjoy
something like
awk '{print $1, $2/1024, "MB"}' /proc/meminfo | egrep 'Used|Free'
You can get other values by adding things to your grep command.
You can also put this in a shell script and then call it from "watch"
or add your own loop like
while clear; do
awk '{print $1, $2/1024, "MB"}' /proc/meminfo | egrep 'Used|Free'
sleep 2
done
There are values that top has that this won't get you because you
would need to calculate FooTotal-FooFree to get FooUsed for certain
values of Foo. This should be easy to do in awk. For example:
awk '{values[$1] = $2/1024};
END {print "SwapUsed:", values["SwapTotal:"] - values["SwapFree:"]}'
/proc/meminfo
--
Seth David Schoen <schoen loyalty.org> | This is a new focus for the security
http://www.loyalty.org/~schoen/ | community. The actual user of the PC
http://vitanuova.loyalty.org/ | [...] is the enemy.
| -- David Aucsmith, IDF 1999
----- End forwarded message -----
More information about the vox-tech
mailing list